您现在的位置是: 首页 > 后端开发 Laravel Dingo/api 出现 The version given was unknown or has no registered routes.报错
Laravel Dingo/api 出现 The version given was unknown or has no registered routes.报错
2020-05-20 【后端开发】 4235人已围观 10620次浏览
简介Laravel Dingo/api 出现 The version given was unknown or has no registered routes.报错
项目部署到生产环境后,使用
php artisan route:cache
对Laravel项目路由进行缓存后,访问API接口出现The version given was unknown or has no registered routes.报错
通过查看项目文件目录bootstrap/cache/下面的routes.php发现config/api.php中写的Dingo Api的路由信息并没有缓存起来。也就直接导致了在访问api接口时出现的路由未注册的提示,因为缓存文件里面根本没有此路由信息。
查看Dingo/api官方wiki发现Dingo/api的路由信息实际应该是单独的命令去进行缓存,也就是
php artisan api:cache
然后再访问API接口则正常返回,并且项目文件目录bootstrap/cache/下面的routes.php中也缓存了api.php中的路由信息。
可能会出现的误区:
1.根据文档说明
提示无法序列化闭包。而在Dingo/api中,实际路由一般都是闭包形式编写的。
2.在查找文档的过程中,发现有人在对api.php路由进行缓存时出现下面的错误提示
Unable to prepare route [/api/version] for serialization.
此类报错一般都是Laravel项目默认的路由没删除的。
也有可能不是这条报错,但也是类似的,比如我自己的,实际删掉api.php中的
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
即可解决
本文涉及到的文档和问答引用自
LearnKu社区问答
https://learnku.com/laravel/t/9905/in-the-course-of-the-tutorial-the-routing-of-api-uses-closures-to-write-a-problem
Dingo/api官方wiki
https://github.com/dingo/api/wiki/Commands#apicache
很赞哦! (0)
相关文章
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- 删除Git仓库所有历史提交记录,成为一个干净的仓库
- Laravel项目出现could not be opened: failed to open stream: Permission denied
- SpringBoot 启动测试时出现提示 Test class should have exactly one public zero-argument constructor
- PHP 中list()出现Undefined offset: 0错误
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- SpringBoot 2.x Security security.basic.enabled=false 失效问题解决
- PHP 在执行 composer install 时出现提示 PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...>
- Nestedset 出现 Node must exists. 错误解决方案
- 记一次Java MessageFormat.format踩坑
点击排行
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- Debian apt 使用国内镜像
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- SpringBoot @NotBlank 不生效问题
- 记一次 Mybatis-Plus 自动填充无效问题解决
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes
- nuxt 项目完整部署方案
站长推荐
猜你喜欢
- gulp3 在 node12 上运行出现异常 primordials is not defined
- win10 cmder Debian 安装配置 oh-my-zsh
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- CentOS 安装Node.js
- CentOS 安装JDK
- cmder vim方向键无法使用 解决方案
- Docker 批量操作命令
- PHP 在执行 composer install 时出现提示 PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...>
- Nginx转发阿里云OSS内网流量
- 在使用Flutter进行网络请求时,使用Dio访问https地址出现unable to get local issuer certificate错误