您现在的位置是: 首页 > 后端开发 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 【后端开发】 3358人已围观 7853次浏览
简介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)
相关文章
- springboot引入mybatis-plus后出现ClassNotFoundException: org.mybatis.logging.LoggerFactory
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes
- SqlServer 查询包含指定字段的存储过程
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- SqlServer 刷新所有视图
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- 记一次Java MessageFormat.format踩坑
- Laravel项目出现could not be opened: failed to open stream: Permission denied
- Nestedset 出现 Node must exists. 错误解决方案
点击排行
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- Debian apt 使用国内镜像
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- SpringBoot @NotBlank 不生效问题
- 记一次 Mybatis-Plus 自动填充无效问题解决
- nuxt 项目完整部署方案
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes