所以,我有一个API端点/api/v1/xxx
,可以调用单个控制器和方法。
在routes/api.php
我添加了以下逻辑
if (Auth::guard('api')->guest()) {
Route::post('xxx', 'API\v1\XXController@xx');
} else {
Route::post('xxx', 'API\v1\XXController@xx')->middleware('auth:api');
}
一切正常,除非我运行composer install
,我收到以下错误:
a@b /var/www/html/test/app13 $ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
[LogicException]
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
Script php artisan optimize handling the post-install-cmd event returned with error code 1
当我运行routes/api.php
时,删除composer install
中的行不会输出^错误。
我做错了什么?
感谢您的帮助。
答案 0 :(得分:0)
密钥路径“file:///var/www/html/test/app13/storage/oauth-public.key”不存在或不可读
以上几行说明了所有内容,您已laravel/passport
已安装并已启用,但您忘记生成密钥,
运行命令
php artisan passport:install
它会正常工作。