laravel/lumen-installer
Official Laravel Lumen project installer. Provides the lumen command to quickly scaffold new Lumen applications, including recommended defaults and project structure. Install via Composer and run lumen new <app> to get started.
Installation:
composer create-project --prefer-dist laravel/lumen-installer project-name
First Use Case:
project-name and run:
php -S localhost:8000 -t public
http://localhost:8000 to verify the default Lumen "Hello World" response.Where to Look First:
bootstrap/app.php: Entry point for the application (similar to Laravel’s index.php).routes/web.php: Default routes (e.g., / and /api).app/Http/Middleware/: Predefined middleware (e.g., VerifyCsrfToken).config/: Default Lumen configurations (e.g., app.php, database.php).Scaffolding a New Project:
routes/web.php, app/Providers/AppServiceProvider.php).Integrating with Laravel Ecosystem:
bootstrap/app.php:
$app->register(App\Providers\AppServiceProvider::class);
$app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class,
]);
config/database.php and use Eloquent models (Lumen supports Laravel’s ORM).API Development:
$router->get('/users', 'UserController@index');
return new UserResource(User::all());
Testing:
Http::get(), Http::post()) or PHPUnit.$response = $this->get('/');
$response->assertStatus(200);
Environment Configuration:
.env files for environment-specific settings (e.g., database connections, API keys).bootstrap/app.php:
$app->withFacades();
$app->withEloquent();
laravel/scout, spatie/laravel-permission) work with Lumen with minor adjustments (e.g., service provider registration).$app->command('custom:command', CustomCommand::class);
config/queue.php) with php artisan queue:work.Middleware Differences:
ShareErrorsFromSession) may not work out-of-the-box.bootstrap/app.php.Service Container:
app()->makeWith()) may not be available.public function __construct(UserRepository $users) { ... }
Routing Conflicts:
laravel/lumen-framework v7+ supports views).Route::view() for simple web routes:
$router->get('/', function () {
return view('welcome');
});
Database Migrations:
migrate Artisan command is not included by default.laravel/framework (if needed) or use raw PDO queries.Caching:
predis/predis and configure config/cache.php.$app->error(function ($request, $exception) {
return response()->json([
'error' => $exception->getMessage(),
], 500);
});
config/app.php to use Monolog:
'log' => 'single',
storage/logs/lumen.log.Environment Files:
.env files from the project root. Ensure .env.example is included for deployment.php artisan config:clear to reload configurations after changes.Service Provider Order:
AppServiceProvider:
public function boot() {
$this->app->bind('customService', function () { ... });
}
Routing Groups:
Route::group() supports middleware and namespace:
$router->group(['middleware' => 'auth'], function () {
$router->get('/profile', 'UserController@profile');
});
Custom Installer Templates:
README.md stub or custom .gitignore).Post-Install Hooks:
composer post-install-cmd in composer.json):
"scripts": {
"post-install-cmd": [
"php artisan key:generate",
"php artisan config:clear"
]
}
Lumen Framework Updates:
laravel/lumen-framework. Pin the version in composer.json to avoid breaking changes:
"require": {
"laravel/lumen-framework": "6.*"
}
How can I help you explore Laravel packages today?