How ouhssini/installer works
Purpose and Integration
This is a Composer package that adds a pre-application Laravel 11/12 installation wizard for commercial deployments. It configures the app, validates host requirements, provisions the database, optionally verifies an Envato license, creates an administrator, then locks itself. Package bootstrapping and container registration are centered in src/InstallerServiceProvider.php; public package access is exposed through src/Installer.php and src/Facades/Installer.php.
Entrypoints and Route Boundary
Browser entry is the configurable /install route prefix declared in routes/installer.php. The wizard is split into request controllers under src/Http/Controllers/, including WelcomeController.php, DatabaseController.php, and FinalizeController.php. Views are server-rendered Blade templates in resources/views/, with shared shell markup at resources/views/layouts/master.blade.php.
Installer routes run in a custom middleware context intended to work before .env and APP_KEY exist; forms are deliberately stateless and do not depend on encrypted sessions or CSRF state.
Installation State and Sequencing
src/Services/InstallerService.php is the installation-state authority. It persists progress/settings file-first under storage/app, avoiding a database dependency before credentials are configured. It tracks completed stages, supports step-order validation, and creates/removes the installation lock. src/Http/Middleware/EnsureInstalled.php gates the host application until completion, while src/Http/Middleware/RedirectIfInstalled.php prevents reopening the wizard after lockout.
The recovery CLI entry point is src/Commands/InstallerCommand.php (php artisan installer:unlock), which removes the installed state when recovery is required.
Environment and Requirements Stage
Application configuration is handled by src/Http/Controllers/AppConfigController.php backed by src/Services/EnvironmentManager.php. This stage creates/updates .env, sets application values, and generates the app key. Requirements validation is isolated in src/Services/RequirementsChecker.php and driven by src/Http/Controllers/RequirementsController.php; configured PHP version, extensions, and writable paths come from config/installer.php.
Database Provisioning Stage
src/Http/Controllers/DatabaseController.php orchestrates connection input, connection testing, environment persistence, migrations, and settings-table initialization. The database-specific boundary is src/Services/DatabaseManager.php, supporting MySQL, PostgreSQL, and SQLite through Laravel’s database/schema facilities. Migrations occur before admin creation so application tables, especially users, exist when later stages execute. The package migration template is database/migrations/create_settings_table.php.stub.
License Verification Boundary
src/Http/Controllers/LicenseController.php delegates purchase-code validation to src/Services/LicenseService.php, which returns the structured src/Services/LicenseVerificationResult.php. This is the external-service boundary for Envato API v3. Behavior is controlled by config/installer.php: verification can be disabled, switched to development mode, or constrained to a configured Envato item. The design stores license metadata and a hash rather than the plaintext purchase code or personal token.
Admin Creation and Finalization
src/Http/Controllers/AdminController.php creates the initial administrator after migrations. It adapts role assignment to the host user schema and can integrate with Spatie Permission when present. src/Http/Controllers/FinalizeController.php completes installation: it syncs file-first installer data to the database settings store, switches relevant runtime drivers toward database-backed operation, marks installation complete, and redirects to the configured post-install route. Primary behavior and defaults are consolidated in config/installer.php.
Main entry points: InstallerService.php Installer state · installer.php Install routes · InstallerServiceProvider.php Installer service provider · DatabaseManager.php Database manager
Components 22
Package Bootstrap
- Installer service provider · Registers package services, routes, middleware, and commands.
src/InstallerServiceProvider.php - Installer public API
src/Installer.php - Installer facade
src/Facades/Installer.php - Installer configuration · Defines route, requirements, license, and post-install behavior.
config/installer.php
Installation Wizard
Stateless browser flow under the install route.
- Install routes · Configurable /install browser entrypoint.
routes/installer.php - Blade wizard views · Shared shell and installation forms.
resources/views/layouts/master.blade.php - App configuration
src/Http/Controllers/AppConfigController.php - Requirements stage
src/Http/Controllers/RequirementsController.php - Database stage · Tests, persists, migrates, and initializes database settings.
src/Http/Controllers/DatabaseController.php - License stage
src/Http/Controllers/LicenseController.php - Admin creation · Creates the initial administrator after migrations.
src/Http/Controllers/AdminController.php - Finalization · Syncs settings, marks complete, and redirects.
src/Http/Controllers/FinalizeController.php
Installation Services
- Installer state · File-first progress, settings, sequencing, and install lock authority.
src/Services/InstallerService.php - Environment manager · Writes .env values and generates the application key.
src/Services/EnvironmentManager.php - Requirements checker · Checks configured PHP, extensions, and writable paths.
src/Services/RequirementsChecker.php - Database manager · Uses Laravel database/schema facilities for MySQL, PostgreSQL, and SQLite.
src/Services/DatabaseManager.php - Settings migration template
database/migrations/create_settings_table.php.stub - Envato license service · Verifies purchase codes without retaining plaintext credentials.
src/Services/LicenseService.php - License verification result · Structured verification outcome and metadata.
src/Services/LicenseVerificationResult.php
Host Application
- Installed gate · Blocks host application access until installation completes.
src/Http/Middleware/EnsureInstalled.php - Wizard lockout · Prevents reopening the wizard after completion.
src/Http/Middleware/RedirectIfInstalled.php - installer:unlock · Removes installed state for recovery.
src/Commands/InstallerCommand.php
Connections 27
- Installer service provider → Installer public API: registers
- Installer facade → Installer public API: facade access
- Installer service provider → Install routes: loads
- Installer service provider → Installed gate: registers
- Installer service provider → installer:unlock: registers
- Installer configuration → Install routes: configures prefix
- Installer configuration → Requirements checker: defines checks
- Installer configuration → Envato license service: controls verification
- Install routes → Wizard lockout: middleware
- Install routes → Blade wizard views: renders
- Install routes → App configuration: wizard flow
- App configuration → Environment manager: updates .env
- Requirements stage → Requirements checker: validates host
- Database stage → Environment manager: persists credentials
- Database stage → Database manager: tests and provisions
- Database manager → Settings migration template: runs migration
- License stage → Envato license service: verifies code
- Envato license service → License verification result: returns
- App configuration → Installer state: records stage
- Database stage → Installer state: records stage
- License stage → Installer state: stores metadata
- Admin creation → Database manager: requires migrated users
- Finalization → Installer state: locks installation
- Finalization → Database manager: syncs settings
- Installer state → Installed gate: completion state
- Installer state → Wizard lockout: lock state
- installer:unlock → Installer state: clears lock