Thinkphp6框架学习:($this->error()undefined)Call to undefined method app\index\controller\Admin::error()
最近在使用Thinkphp6框架的时候,想做一个初始化来验证登录状态。
当没有Session::get(‘adminUid’)的时候就应该跳转到admin\adminLogin的方法中,和以前Tp5的框架一样,使用$this->error()的方法
结果就报错:
Call to undefined method app\index\controller\Admin::error()

昨天的时候就觉得很苦恼很奇怪,明明之前使用的时候是完全没有问题的,现在怎么就不行了。
但现在使用Tp6框架的人还是太少了,昨天也查不出一个所以然,于是就每个方法都写了一条验证Session的语句(很蠢的方法)。
今天又想了一下,觉得这样写太憨了...然后就翻了一下Tp6的官方手册!果然和框架升级有密切关系!!


太可恶了!
当然也有解决方法:在根目录下面打开cmd(或者在ide中的终端),输入这个:
composer require qeq66/think-jump
安装好之后就可以正常使用了


安装好之后的文件夹在这里

在控制器里面引入类

正常使用

看了一下源码,还是不行。
新的Jump类和之前不同,不能够成功跳转到抛错模板中。
将Jump类改得和Tp5框架一模一样之后,依旧报错。
原因是数组的变量不一致。
继续看源码。
原因是
Tp6框架中的抛错响应的类和之前的也不一样。
加了很多变量,什么$app之类的。
改动太大了,而且现在感觉框架里面bug还是很多,
别写Tp6了!!
(用回Tp5.1移植+测试接口20min,很是舒服)
Thinkphp6框架学习:($this->error()undefined)Call to undefined method app\index\controller\Admin::error()的更多相关文章
- thinkphp报错Call to undefined method app\index\controller\Index::fetch()
因为要写一个系统,所以又重新下载了thinkphp,然后安装了一下.回忆起这个问题很容易让新手朋友费解.会出现如下报错:Call to undefined method app\index\contr ...
- ORA-28547: connection to server failed, probable Oracle Net admin error
现象 C:\Users\Administrator>sqlplus scott/tiger@192.168.1.11:1521/orcl SQL*Plus: Release 11.2.0.4.0 ...
- stm32 usb error : identifier "bool" is undefined
.\usb\USB\usb_pwr.h(54): error: #20: identifier "bool" is undefinedusb\USB\usb_pwr.h(54): ...
- "undefined method `root' for nil:NilClass" error when using "pod install" 解决办法
如果pod undate 的时候报错"undefined method `root' for nil:NilClass" error when using "pod in ...
- Hadoop Streaming框架学习2
Hadoop Streaming框架学习(二) 1.常用Streaming命令介绍 使用下面的命令运行Streaming MapReduce程序: 1: $HADOOP_HOME/bin/hadoop ...
- fastDfs V5.02 升级到 V5.08版本后,启动报错:symbol lookup error: /usr/bin/fdfs_trackerd: undefined symbol: g_current_time
/libfastcommon-1.0.36 # ./make.sh cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o hash.o ...
- Appium 连手机失败Error: Android bootstrap socket crashed: Error: getaddrinfo ENOTFOUND localhost undefined:4724
问题:Appium执行,连接手机报下面的错误 Error: Android bootstrap socket crashed: Error: getaddrinfo ENOTFOUND localho ...
- mac安装protobuf2.4.1时报错./include/gtest/internal/gtest-port.h:428:10: fatal error: 'tr1/tuple' file not found和google/protobuf/message.cc:175:16: error: implicit instantiation of undefined template
通过网上下载的protobuf2.4.1的压缩文件,然后进行安装,./configure和make时遇到了两个问题. 正常的安装步骤如下: ./configure make make check m ...
- WebGL——osg框架学习一
从今天开始,我们开始正式的学习osg框架,今天我们学习的是osg的渲染模块,我们来看一下代码结构. 所有DrawXXX的js模块都是渲染的模块,我们逐一来简单介绍一下,第一个Drawable.js,这 ...
随机推荐
- C++入门经典-例9.3-类模板,简单类模板
1:使用template关键字不但可以定义函数模板,而且可以定义类模板.类模板代表一族类,它是用来描述通用数据类型或处理方法的机制,它使类中的一些数据成员和成员函数的参数或返回值可以取任意数据类型.类 ...
- When Database Sharding is Appropriate DATABASE SHARDING
w横切 http://www.agildata.com/database-sharding/ When Database Sharding is Appropriate Database Shardi ...
- json-lib json反序列化——日期转换
将json格式的字符串转为对象,其中key-value有将String的日期转为Date类型,怪现象就是,转出来的Date类型的值是当前的系统时间. 网上有许多答案,在反序列化之前需要注册Date解析 ...
- 四、使用jsonpath-JSON Extractor提取复杂响应中的数组及其他字段
一.jsonpath实时调试url http://jsonpath.com/ 二.对于复杂响应的提取字段 1.json字符串如下: { "code": 0, "data& ...
- 三、SpringBoot启动时JDBC报错:You must configure either the server or JDBC driver (via the serverTimezone configuration property)
错误提示: Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connectio ...
- 数据中心网络架构的问题与演进 — Overlay 网络
目录 文章目录 目录 前文列表 数据中心网络架构演进回顾 Overlay 网络 Overlay 网络的优势 基于 VxLAN Overlay 的 Spine-Leaf 网络架构 参考文章 前文列表 & ...
- redis(3)主从与集群
一.主从架构 yum安装的redis cd /etc/ cp redis.conf /etc/slave.conf vim slave.conf bind 192.168.42.7 slaveof p ...
- mongod 对指定数据库创建用户
https://blog.51cto.com/wzlinux/2153062?source=dra 1.先在admin库中创建管理员用户与密码 [root@mbasic ~]# mongo Mongo ...
- linux常用命令(10)more命令
more命令,功能类似 cat ,cat命令是整个文件的内容从上到下显示在屏幕上. more会以一页一页的显示方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会 ...
- Python基于回溯法解决01背包问题实例
Python基于回溯法解决01背包问题实例 这篇文章主要介绍了Python基于回溯法解决01背包问题,结合实例形式分析了Python回溯法采用深度优先策略搜索解决01背包问题的相关操作技巧,需要的朋友 ...