Lumen alongside Laravel 5

Submitted by kamaroly - 2 years ago

If you want to add Lumen to your laravel 5 and you don't want to create new repositories models controllers etc... Just create a new Lumen project and autoload laravel namespace in lumen composer.json I assume both laravel5 and lumen are in the same directory but each one in it's own project directory.

    /** Your lumen composer.json **/
    "autoload": {
        "psr-4": {
            "App\\": "app/", //Lumen namespace
            "Laravel\\":"../Laravel5/app" // Laravel namespace
        },
    
    /** Run composer dump-autoload -o **/
    // FROM YOUR LUMEN APP YOU CAN USER ANY CLASS UNDER Laravel namespace 
    // Then in your Lumen/app/Http/routes.php you can call laravel classes like below 
    $app->get('api/v1',function()
    {
		return \Laravel\User::all(); //Note that I Started namespace with \
	});
    

Ads cover the costs of maintaining Laravel-tricks

comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks