4

I am having some trouble with creating my API using Restler while using log4php. It seems to be a clash in the autoloaders but I am not certain. For reference I will try just showing the relevant code sections so it will hopefully help.

In index.php I have:

require_once("../../config.php");
require_once("../../lib/Luracast/restler.php");
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Messages');
$r->addAuthenticationClass('APIAuth');
$r->handle(); //serve the response

where config.php is the loading and configuration of my app. Inside of that is:

require_once(SYS_PATH.'/lib/log4php/Logger.php');
Logger::configure(SYS_PATH.'/../resources/log4php.xml');
$syslog = Logger::getLogger('System');

My Messages API that I am building so far simply contains:

class Messages {
    function get($id) {
        return MessageService::getMessage($id);
    }
}

Finally, inside of MessageService we have:

static function getMessage($msgId) {
    global $syslog;
    $syslog->debug("Getting message for id $msgId");
    //extraneous code removed
}

When I do that and try accessing the API for the messages/get api function, I get the following error:

Fatal error: Class 'LoggerLoggingEvent' not found in /path/to/lib/log4php/Logger.php on line 290

Have reviewed and looked at https://github.com/Luracast/Restler/issues/72 -- which seems to indicate there should be no issue, but I am not certain or must be doing something wrong.

Hopefully that all makes sense and is clear, if there is something I am missing let me know. I am using Restler 3.0RC3.

0 Answers0