Error: Class 'SimplePasswordHasher' not found

来源:互联网 发布:搭建视频解析接口源码 编辑:程序博客网 时间:2024/06/03 01:42

PHP新手,在跟着the guide of cakephp(http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html)做练习时,访问这个/cakephp/users/add url时出现这个错误:

Error: Class 'SimplePasswordHasher' not found

自己猜测应该是没有导入这个类,按照App::uses('AppModel', 'Model');这样添加,我写成:

App::uses('SimplePasswordHasher', 'SimplePasswordHasher');

结果还是错的,在Google上搜索了一下,发现应该是这样添加:

App::uses('SimplePasswordHasher', 'Controller/Component/Auth');


参考的文章:

http://cakephp.1045679.n5.nabble.com/Error-Class-SimplePasswordHasher-not-found-td5717231.html


Hi All,


I hope you can point me in the right direction.

I'm following the guide at: http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

I'm using CakePHP 2.4.3 and have followed the guide to the letter of the law. It mostly works correctly. If I try to access a controller/action it redirects as it should to the users/login action... so that's seems fine.

The issue is when I try to add a new user at users/add. It throws this error: Error: Class 'SimplePasswordHasher' not found

I have made sure that the following is pasted in the top of the Users model: App::uses('AppModel', 'Model', 'SimplePasswordHasher', 'Controller/Component/Auth');

I then thought that perhaps this "SimplePasswordHasher" class was a new thing part of 2.4.4 so I set up another test project to test it and went through the entire Auth tutorial again with exactly the same results.

Where am I going wrong? It there some code missing? 

I had exactly the same issue when I did the tutorial, but it had to do with caching/refreshing because suddenly it worked.
In your case: you do mean the 'User' model; it should not be 'Users'.
I only have 'App::uses('SimplePasswordHasher', 'Controller/Component/Auth');' and it works just fine.


0 0
原创粉丝点击