dusterio / lumen-passport

Making Laravel Passport work with Lumen
MIT License
654 stars 141 forks source link

Lumen 5.6 Call to undefined function Laravel\Passport\config_path() #78

Closed chinbang closed 2 years ago

chinbang commented 6 years ago

screen shot 2561-04-12 at 17 28 51

I follow this step

Run command $ composer create-project --prefer-dist laravel/lumen lumen-app $ cd lumen-app $ composer require dusterio/lumen-passport

Modify the bootstrap flow (bootstrap/app.php file)

// Enable Facades $app->withFacades();

// Enable Eloquent $app->withEloquent();

// Enable auth middleware (shipped with Lumen) $app->routeMiddleware([ 'auth' => App\Http\Middleware\Authenticate::class, ]);

// Finally register two service providers - original one and Lumen adapter $app->register(Laravel\Passport\PassportServiceProvider::class); $app->register(Dusterio\LumenPassport\PassportServiceProvider::class);

After Finnish I use command $ php artisan list

It show message : In PassportServiceProvider.php line 299:
Call to undefined function Laravel\Passport\config_path()

PierreOlivierBrillant commented 6 years ago

I believe it's because of the very new update on Laravel/Passport going from 5.0.3 to 6.0.0.

Lumen-passport seems to be incompatible with this new update. The workaround that I've found on SO is to import an older version of Laravel/Passport (5.0.3) in your composer.json. The thing should look like this:

"laravel/passport": "5.0.3",
"dusterio/lumen-passport": "^0.2.6"

So I guess we have to wait for a fix in lumen-passport.

abdullah-abunada commented 6 years ago

You can add helpers folder in app folder and add helpers.php file app/helpers/helpers.php inside helpers.php add

<?php
if ( ! function_exists('config_path'))
{
    /**
     * Get the configuration path.
     *
     * @param  string $path
     * @return string
     */
    function config_path($path = '')
    {
        return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
    }
}

then add this to composer.json


"autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "files": [
            "app/helpers/helpers.php"
        ]
    },
jbernalgeo commented 6 years ago

then run; composer dump-autoload, thanks!

glmagalhaes commented 6 years ago

@abdullah-abunada Thanks for the solution.

nhepner1 commented 6 years ago

@abdullah-abunada confirming that this worked for me as well.