您现在的位置是: 首页 > 后端开发 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 【后端开发】 3777人已围观 9499次浏览
简介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)
相关文章
- SqlServer字符串处理
- 记一次 Mybatis-Plus 自动填充无效问题解决
- SpringBoot 启动测试时出现提示 Test class should have exactly one public zero-argument constructor
- SqlServer 刷新所有视图
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- 删除Git仓库所有历史提交记录,成为一个干净的仓库
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- 记一次Java MessageFormat.format踩坑
- Laravel项目出现could not be opened: failed to open stream: Permission denied
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
点击排行
- 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 自动填充无效问题解决
- nuxt 项目完整部署方案
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes
站长推荐
猜你喜欢
- Linux 查看磁盘、磁盘分区、挂载磁盘、卸载磁盘操作
- CentOS 7 安装 Golang 环境
- Vue 路由跳转后不在顶部
- Windows CMD 常用命令
- SpringBoot @NotBlank 不生效问题
- Python 钉钉加签 HmacSHA256 算法签名
- nginx 出现 the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in 错误解决方案
- Linux 服务器之间传输大文件(压缩文件、查看MD5、后台传输)
- linux下各文件夹的结构说明及用途介绍
- SqlServer 优化技巧