Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Lumen Framework Laravel Package

laravel/lumen-framework

Core kernel code for Laravel Lumen, the fast PHP micro-framework. Provides the foundation for routing, database abstraction, queues, caching, and more. For building apps, use the main Lumen repository; docs at lumen.laravel.com.

View on GitHub
Deep Wiki
Context7

Getting Started

Lumen is a lightweight micro-framework ideal for high-performance, lightweight APIs—especially where speed and minimal overhead matter. Start by installing via Composer: composer create-project --prefer-dist laravel/lumen myapp. Key entry points: bootstrap/app.php (app bootstrapping, service provider registration) and routes/web.php or routes/api.php (routing). Unlike Laravel, Lumen strips out features like Blade templates, sessions (by default), and many console commands—keeping only essentials like routing, Eloquent (optional), and caching. First use case: building a JSON API with minimal middleware—e.g., quick CRUD endpoints backed by a database using DB or Eloquent (enabled via app->enableEloquent() in bootstrap/app.php).

Implementation Patterns

  • Explicit Enablement: Many features (Eloquent, facades, middleware) are opt-in. In bootstrap/app.php, explicitly call $app->withFacades(), $app->withEloquent(), or register middleware like $app->middleware([...]).
  • Route Definitions: Routes live in routes/web.php (for web-like apps) or routes/api.php (stateless APIs). Use compact closures or explicit controller references:
    $app->get('/users', 'UserController@index'); // or fn() => DB::table('users')->get();
    
  • Middleware: Global middleware in bootstrap/app.php via $app->routeMiddleware([...]) and $app->middleware([...]); route-specific via ->middleware('auth').
  • Console Commands: Create via php artisan make:command, but only register manually in app/Console/Kernel.php (Lumen lacks auto-discovery).
  • Testing: Use Tests\TestCase extending Illuminate\Testing\TestResponse; leverages Laravel’s HTTP testing but without session/blade. Prefer assertJsonStructure() and direct DB assertions.

Gotchas and Tips

  • No Auto-Discovery: Services like app/Providers/EventServiceProvider or app/Providers/AppServiceProvider must be manually registered in bootstrap/app.php under $app->register(...).
  • Facades Optional: Not available by default. Enable with $app->withFacades()—but avoid them in Lumen; prefer dependency injection to reduce coupling.
  • Validation differences: Controller validate() method behaves differently than Laravel (e.g., no ValidationException with custom status code by default in older versions—fixed in v9.1.1+). Use Validator::make() manually or upgrade.
  • Console quirk: Command registration requires Kernel::commands([...]) call; auto-scan (Laravel’s commands() call in app/Console/Kernel.php) is not supported.
  • Debugging: Xdebug can break performance gains—use phpunit with --filter for targeted tests. Misconfigured .env (e.g., missing APP_DEBUG=false) often causes confusing error leaks.
  • Upgrade caution: Lumen follows Laravel version parity (e.g., Lumen 9.x → Laravel 9). Updating lumen-framework often requires同步 laravel/framework dependencies—check composer.lock diff for unintentional Laravel upgrades.
  • Extension tip: For Laravel-like features (e.g., event broadcasting), pull in standalone packages (e.g., laravel/passport) but register providers manually.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
vento/laravel-airbrake
wfeller/laravel-batch
maco-studios/mage-os-installer
busarm/armie
siberfx/laravel-logger
kfteam1991/dcat-admin
dashed/dashed-laposta
dashed/dashed-ecommerce-montaportal
dashed/dashed-ecommerce-etsy
neohq/string-blade-compiler
log1x/acf-composer
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager