Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cakephp 3 Could not load class from Plugin

i have written a Plugin to write the Logs in the Database. My folder structure looks like this:

plugins/Logging/src/Log/Engine/DatabaseLog

The class looks like this:

  <?php

    namespace Logging\Log\Engine;

    use Cake\Log\Engine\BaseLog;
    use Cake\ORM\TableRegistry;

class DatabaseLog extends BaseLog{

private $Model;

public function __construct(array $config = []){
  parent::__construct($config);
}

public function log($level, $message, array $context = []){

//Laden des Models
if(!$context || !array_key_exists('model', $context)){
   $context['model'] = 'SystemLogs';
}
$this->Model = TableRegistry::get($context['model']);

$log_data = [
  'level' => $level,
  'message' => $message
]; 

$entity = $this->Model->newEntity($log_data);
$this->Model->save($entity);

return true;
 }
}
?>

In my app.php:

'Log' => [
  'debug' => [
      'className' => 'Logging.DatabaseLog',
  ]
],

what I need to change so that the class is loaded

Thanks

like image 345
user2016522 Avatar asked Jul 03 '26 17:07

user2016522


1 Answers

Dunno if any one still needs this. But just in case.

I have encountered this a few times since i started using cake 3.

However, as long as i add this line to the end of my root bootstrap.php

Plugin::load('[Name_of_Plugin]', ['bootstrap' => false, 'routes' => true]);

It always work.

Cheers.

like image 169
Ayo Makanjuola Avatar answered Jul 06 '26 06:07

Ayo Makanjuola