⚠️ NativePHP is currently an alpha release and is not ready for production applications yet.
Application Lifecycle

NativePHP Application Lifecycle

When your NativePHP application starts - whether it's in development or production - it performs a series of steps to get your application up and running.

  1. The native shell (Electron or Tauri) is started.
  2. NativePHP runs php artisan migrate to ensure your database is up-to-date.
  3. NativePHP runs php artisan serve to start the PHP development server.
  4. NativePHP boots your application by running the boot() method on your NativeAppServiceProvider.

In addition to the boot() method, NativePHP also dispatches a Native\Laravel\Events\App\ApplicationBooted event.

The NativeAppServiceProvider

When running php artisan native:install, NativePHP publishes a NativeAppServiceProvider to app/Providers/NativeAppServiceProvider.php.

You may use this service provider to boostrap your application. For example, you may want to open a window, register global shortcuts, or configure your application menu.

The default NativeAppServiceProvider looks like this:

1namespace App\Providers;
3use Native\Laravel\Facades\ContextMenu;
4use Native\Laravel\Facades\Dock;
5use Native\Laravel\Facades\Window;
6use Native\Laravel\GlobalShortcut;
7use Native\Laravel\Menu\Menu;
9class NativeAppServiceProvider
11 /**
12 * Executed once the native application has been booted.
13 * Use this method to open windows, register global shortcuts, etc.
14 */
15 public function boot(): void
16 {
17 Menu::new()
18 ->appMenu()
19 ->submenu('About', Menu::new()
20 ->link('', 'NativePHP')
21 )
22 ->submenu('View', Menu::new()
23 ->toggleFullscreen()
24 ->separator()
25 ->toggleDevTools()
26 )
27 ->register();
29 Window::open()
30 ->width(800)
31 ->height(800);
32 }