⚠️
NativePHP is currently in alpha. We do not recommend distributing
production releases of your 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.
- The native shell (Electron or Tauri) is started.
- NativePHP runs
php artisan migrate
to ensure your database is up-to-date. - NativePHP runs
php artisan serve
to start the PHP development server. - NativePHP boots your application by running the
boot()
method on yourNativeAppServiceProvider
.
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; 2 3use Native\Laravel\Facades\Window; 4use Native\Laravel\Contracts\ProvidesPhpIni; 5 6class NativeAppServiceProvider implements ProvidesPhpIni 7{ 8 /** 9 * Executed once the native application has been booted.10 * Use this method to open windows, register global shortcuts, etc.11 */12 public function boot(): void13 {14 Window::open();15 }16 17 /**18 * Return an array of php.ini directives to be set.19 */20 public function phpIni(): array21 {22 return [23 ];24 }25}