CakePHP "Fatal error: Class 'Debugger' not found" in a File That Doesn't Reference Debugger
Asked Answered
R

4

7

I'm getting the error referenced in the title from a file that doesn't reference the Debugger class. If I manually import Debugger, the error still shows up. The line number referenced in the error in the last } ending the class definition in the file. Nothing follows the } (there's not ?> either). The file that I'm getting the error in doesn't directly reference Debugger so far as I can tell (as in, there is no explicit use of Debugger).

here's the stack trace:

( ! ) Fatal error: Class 'Debugger' not found in /home/gregg/workspace/Fueled/dapprly/backend/app/Plugin/Facebook/Controller/Component/FapiComponent.php on line 107
Call Stack
#   Time    Memory  Function    Location
1   0.0003  245664  {main}( )   ../index.php:0
2   0.0168  1657712 Dispatcher->dispatch( ) ../index.php:100
3   0.0237  2753568 Dispatcher->_invoke( )  ../Dispatcher.php:85
4   0.0237  2753768 Controller->constructClasses( ) ../Dispatcher.php:99
5   0.0237  2755712 ComponentCollection->init( )    ../Controller.php:638
6   0.0255  3057112 ComponentCollection->load( )    ../ComponentCollection.php:52
7   0.0255  3057600 class_exists ( )    ../ComponentCollection.php:99
8   0.0255  3057896 App::load( )    ../ComponentCollection.php:0
9   0.0257  3091416 ErrorHandler::handleError( )    ../ComponentCollection.php:551

and here's the context around line 107:

class FapiComponent extends Component {
    // -- snip -- //

    public function method()
    {
        $url = urlencode('http://url');

        $param = array(
        'access_token' => '##' ,
        'object' => 'user',
        'fields' => 'feed', 
        'callback_url' => $url);
        $id = $this->facebook->getAppId();
        $subs = $this->facebook->api('/' . $id . '/subscriptions' , 'POST' , $param);
    }
} // <-- line 107 ... nothing after this
Repand answered 2/5, 2012 at 13:53 Comment(2)
Does the Component class use Debugger?Joist
no, I found the error. This class that I've shown has the initialize method implemented. But it's implemented as public function initialize($controller). This is an E_STRICT error. My setup is catching those errors. This error is causing it to look for Debugger. I'm not sure why it's not able to autoload it, but change the method to public function initialize(Controller $controller) fixed the issue I was having.Repand
R
8

I found the error.

This class that I've shown has the initialize method implemented. But it's implemented as

public function initialize($controller)

This is an E_STRICT error since it differs from the parent method by leaving out the type hint. My setup is catching E_STRICT errors. This error is causing it to look for Debugger. I'm not sure why it's not able to autoload it, but changing the method to

public function initialize(Controller $controller)

fixed the issue I was having.

Repand answered 2/5, 2012 at 14:17 Comment(1)
I also found out that this happened because PHP 5.4 includes E_STRICT in the E_ALL set now. So you need to specifically exclude8 E_STRICT if you don't want to see those errors. In php 5.3 you had to specifically *include E_STRICT if you wanted to see those errors.Repand
P
13

This is due to a a PHP bug that did not perform auto loading for compile time errors (e.g., E_STRICT).

This was fixed in PHP 5.4.21 and a workaround pull request was accepted by CakePHP.

To manually workaround this issue and exempt E_STRICT from CakePHP's error handler:

  1. Open core.php in your preferred editor (you could find the file by performing something like find . -name core.php).
  2. Find the following line: 'level' => E_ALL & ~E_DEPRECATED,
  3. Replace it with: 'level' => E_ALL & ~E_DEPRECATED & ~E_STRICT,
Pullulate answered 18/2, 2013 at 23:16 Comment(0)
R
8

I found the error.

This class that I've shown has the initialize method implemented. But it's implemented as

public function initialize($controller)

This is an E_STRICT error since it differs from the parent method by leaving out the type hint. My setup is catching E_STRICT errors. This error is causing it to look for Debugger. I'm not sure why it's not able to autoload it, but changing the method to

public function initialize(Controller $controller)

fixed the issue I was having.

Repand answered 2/5, 2012 at 14:17 Comment(1)
I also found out that this happened because PHP 5.4 includes E_STRICT in the E_ALL set now. So you need to specifically exclude8 E_STRICT if you don't want to see those errors. In php 5.3 you had to specifically *include E_STRICT if you wanted to see those errors.Repand
A
0

This occurs any time you have an E_STRICT error. The main one I had was when running PHP 5.4, you are required to have public, private, and protected function declarations.

Aureolin answered 15/10, 2012 at 22:52 Comment(0)
K
0

The problem is that php lower than version 5.4.21 has an issue with the autoloader on E_STRICT errors. (E_STRICT is a compile time error)

https://bugs.php.net/bug.php?id=65322

I encountered the exact same issue on some old projects, and It's fixed in 2.7.4.

https://github.com/cakephp/cakephp/issues/7376

So the real solution is to upgrade to at least 5.4.21 or wait for CakePHP 2.7.4

Kellyekellyn answered 11/9, 2015 at 13:47 Comment(2)
same problem with php 5.5.Sometimes the root of the problem is elsewhere.Dianthe
I guess the same issue was also active in php 5.5Kellyekellyn

© 2022 - 2024 — McMap. All rights reserved.