流明护照不能php工匠迁移?

时间:2018-04-09 19:06:33

标签: php lumen

我在尝试安装dusterio / lumen-passport时遇到了问题。我已根据他们在githubpackagist.org提供的步骤进行了尝试。

问题是每次我做

  

php artisan migrate

命令,总是这样说:

  

在PassportServiceProvider.php第299行:

     
    

调用未定义的函数Laravel \ Passport \ config_path()

  

这是我的bootsrap / app.php

<?php

require_once __DIR__.'/../vendor/autoload.php';

try {
    (new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
    //
}

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

 $app->withFacades();

 $app->withEloquent();

/*
|--------------------------------------------------------------------------
| Register Container Bindings
|--------------------------------------------------------------------------
|
| Now we will register a few bindings in the service container. We will
| register the exception handler and the console kernel. You may add
| your own bindings here if you like or you can make another file.
|
*/

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);

/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/

// $app->middleware([
//    App\Http\Middleware\ExampleMiddleware::class
// ]);

 $app->routeMiddleware([
     'auth' => App\Http\Middleware\Authenticate::class,
 ]);

/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/

$app->register(App\Providers\AppServiceProvider::class);
$app->register(App\Providers\AuthServiceProvider::class);
$app->register(App\Providers\EventServiceProvider::class);
$app->register(Laravel\Passport\PassportServiceProvider::class);
$app->register(Dusterio\LumenPassport\PassportServiceProvider::class);

/*
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
|
| Next we will include the routes file so that they can all be added to
| the application. This will provide all of the URLs the application
| can respond to, as well as the controllers that may handle them.
|
*/

$app->router->group([
    'namespace' => 'App\Http\Controllers',
], function ($router) {
    require __DIR__.'/../routes/web.php';
});

return $app;
我做错了什么?我试图在谷歌搜索但我还没有找到任何东西:(

2 个答案:

答案 0 :(得分:0)

这是因为Lumen没有一些laravel辅助函数。在这种情况下,它是'config_path()'函数。

这是解决方案

  1. 安装最新的Passport程序包
  2. 安装此插件composer require irazasyed/larasupport
  3. 将以下类添加到您的服务提供商(app.php)

    $app->register(Irazasyed\Larasupport\Providers\ArtisanServiceProvider::class);

  4. 使用composer update

  5. 更新作曲家
  6. 立即迁移(php artisan migrate)

  7. 这应该可以解决您的问题。

答案 1 :(得分:0)

您可以在app文件夹中添加helpers文件夹,并添加helpers.php文件app/helpers/helpers.php

helpers.php内添加

<?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);
    }
}

然后将其添加到composer.json

"autoload": {
    "psr-4": {
        "App\\": "app/"
    },
    "files": [
        "app/helpers/helpers.php"
    ]
},

然后跑步

composer dump-autoload