开发者

CakePHP fatal error: Class 'ErrorHandler' not found

开发者 https://www.devze.com 2023-01-27 19:41 出处:网络
I\'ve generated testsuits via \"cake bake testsuit\" and used localhost/test.php for my app. So, the is an error when I tried to run one of test (e开发者_JS百科lse tests are valid):

I've generated testsuits via "cake bake testsuit" and used localhost/test.php for my app. So, the is an error when I tried to run one of test (e开发者_JS百科lse tests are valid):

Fatal error: Class 'ErrorHandler' not found in Z:\home\prodvigator\www\cake\libs\object.php on line 201
This models and controllers are generated by scaffold and I don't think that an error is in this sources.

Using: CakePHP 1.3 The latest SimpleTest


In my case, deleting all the files in the folder /app/tmp/cache/persistent solved the problem.


try checking the generated tests for an error that gets written at the top of the file.

sometimes i've been known to find something like this in both model and controller tests.

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /projectname/cake/console/templates/default/classes/test.ctp on line 22


In my case, the error was:

Fatal error: Uncaught Error: Class 'ErrorHandler' not found in C:\[path]\core\cake\libs\object.php on line 211
( ! ) Error: Class 'ErrorHandler' not found in C:\[path]\core\cake\libs\object.php on line 211

The error was happening to me when trying to visit http://localhost/user_accounts/index

I already had the view created at app\views\user_accounts\index.ctp with the following content:

<div>
    Text from div
</div>

I had created the corresponding controller as well at app\controllers\user_accounts_controller.php:

<?php 
    class UserAccountsController extends AppController {
        public function index() {
            // Render the view in /views/user_accounts/index.ctp
            $this->render();
        }
    }
?>

Since I was not associating a model to this controller, I was missing this: var $uses = array();. It would have saved me time if the error had been more explicit, something such as "You do not have a model associated to this controller".

The fix was:

<?php 
    class UserAccountsController extends AppController {
        // Use this controller without a need for a corresponding Model file.
        var $uses = array();
        public function index() {
            // Render the view in /views/user_accounts/index.ctp
            $this->render();
        }
    }
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号