我已经安装了Lumen,Dingo来测试JWT集成。
在终端上,当我尝试使用php artisan命令运行单元测试用例时,它会抛出以下错误
PHP Fatal error: Call to undefined function Dingo\Api\Provider\config_path() in /usr/local/var/www/vhosts/storm/vendor/dingo/api/src/Provider/LaravelServiceProvider.php on line 26
PHP Stack trace:
PHP 1. {main}() /usr/local/var/www/vhosts/xxx/artisan:0
PHP 2. require() /usr/local/var/www/vhosts/xxx/artisan:18
PHP 3. Laravel\Lumen\Application->register() /usr/local/var/www/vhosts/storm/bootstrap/app.php:84
PHP 4. Illuminate\Container\Container->call() /usr/local/var/www/vhosts/storm/vendor/laravel/lumen-framework/src/Application.php:176
PHP 5. Illuminate\Container\BoundMethod::call() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/Container.php:531
PHP 6. Illuminate\Container\BoundMethod::callBoundMethod() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:31
PHP 7. Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:87
PHP 8. call_user_func_array:{/usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:30}() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:30
PHP 9. Dingo\Api\Provider\LaravelServiceProvider->boot() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:30
我的composer.json
:
"laravel/lumen-framework": "5.4.*",
"vlucas/phpdotenv": "~2.2",
"dingo/api": "1.0.*@dev",
"guzzlehttp/guzzle": "^6.2",
"lukasoppermann/http-status": "^2.0"
任何php artisan
命令都会抛出错误。
答案 0 :(得分:1)
我只能怀疑您注册LaravelServiceProvider
而非使用LumenServiceProvider
。
由于Lumen 没有帮助函数config_path()
,因此您收到此错误。
所以根据install instructions你应该添加
$app->register(Dingo\Api\Provider\LumenServiceProvider::class);
到bootstrap/app.php
。