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) is started.
- NativePHP runs
php artisan migrateto ensure your database is up-to-date. - NativePHP runs
php artisan serveto start the PHP development server. - NativePHP boots your application by running the
boot()method on yourNativeAppServiceProvider. - NativePHP also dispatches a
ApplicationBootedevent.
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:
Copied!
namespace App\Providers; use Native\Desktop\Facades\Window;use Native\Desktop\Contracts\ProvidesPhpIni; class NativeAppServiceProvider implements ProvidesPhpIni{ /** * Executed once the native application has been booted. * Use this method to open windows, register global shortcuts, etc. */ public function boot(): void { Window::open(); } /** * Return an array of php.ini directives to be set. */ public function phpIni(): array { return [ ]; }}
Events#
ApplicationBooted#
As mentioned above, the Native\Desktop\Events\App\ApplicationBooted event is dispatched when your application has been booted.
NativePHP
Bring your
Laravel
skills to
mobile apps.
Cloud Platform
Bifrost
Build your NativePHP apps
in the cloud.
Ship it!
Plans from $19/mo
NativePHP Ultra
All NativePHP plugins, teams & priority support from
$35/mo
Learn More
The Vibes
The unofficial Laracon US
Day 3
Grab Your Spot
Only 100 tickets!
The Masterclass
Go from zero to
published app
in no time
in no time
Learn More