所以,我有一个调用单个控制器和方法的 API 端点/api/v1/xxx
。
在routes/api.php
中,我添加了以下逻辑
if (Auth::guard('api')->guest()) {
Route::post('xxx', 'APIv1XXController@xx');
} else {
Route::post('xxx', 'APIv1XXController@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
> IlluminateFoundationComposerScripts::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
.
我做错了什么?
感谢您的任何帮助。
键路径"file:///var/www/html/test/app13/storage/oauth-public.key"不存在或不可读
上面的几行说明了一切,您已经安装并启用了laravel/passport
但您忘记生成密钥,
运行命令
php artisan passport:install
它会正常工作。