您现在的位置是: 首页 > 后端开发 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 【后端开发】 4496人已围观 11107次浏览
简介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)
相关文章
- 记一次 Mybatis-Plus 自动填充无效问题解决
- SqlServer字符串处理
- springboot引入mybatis-plus后出现ClassNotFoundException: org.mybatis.logging.LoggerFactory
- SpringBoot 2.x Security security.basic.enabled=false 失效问题解决
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes
- 获取阿里云CDN真实IP
- 删除Git仓库所有历史提交记录,成为一个干净的仓库
- SqlServer 查询包含指定字段的存储过程
- PHP 中list()出现Undefined offset: 0错误
- SpringBoot 定时任务 多线程
点击排行
- 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 项目完整部署方案
站长推荐
猜你喜欢
- Linux 安装 Tengine
- SpringBoot 启动提示 Requested bean is currently in creation: Is there an unresolvable circular reference?
- Laravel Dingo/api 出现 The version given was unknown or has no registered routes.报错
- docker mysql 导入 SQL 脚本
- layUI点击按钮页面刷新问题解决方案
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- LNMP 手动更新 SSL 证书
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- Nginx转发阿里云OSS内网流量
- CentOS 安装JDK