CakePHP 4 with AdminLTE

Hello,
please, maybe could someone know a tutorial to implement AdminLTE with CakePHP 4.0.5?

And, maybe, someone knows a good online course about CakePHP 4.0.5?

Thank you in advance.

BR,
Dante

I am using https://github.com/maiconpinto/cakephp-adminlte-theme with 3.7 and it works well.

It says it compatible with version 4.

Hi Jubbs,
thank you for the feedback.

I have tried many times and nothing.
I came always with the error below:

return [ 'Theme' => [ 'title' => 'ormDB', 'logo' => [ 'mini' => 'oDB', 'large' => 'ORMDB', ], 'login' => [ 'show_remember' => true, 'show_register' => true, 'show_social' => true, ], 'folder' => ROOT, 'skin' => 'blue', ] ];Config file "adminlte.php" did not return an array

And I am getting the error bellow:

Thank you for your attention and help.
Best regards,
Dante

The actual error:

[ Warning (2)](javascript:void(0);): Could not check compatibility between App\Controller\AppController::beforeRender(App\Controller\EventInterface $event) and Cake\Controller\Controller::beforeRender(Cake\Event\EventInterface $event), because class App\Controller\EventInterface is not available [ APP/Controller\AppController.php , line 54 ]

[ Warning (2)](javascript:void(0);): Could not check compatibility between App\Controller\ErrorController::beforeRender(Cake\Event\EventInterface $event) and App\Controller\AppController::beforeRender(App\Controller\EventInterface $event), because class App\Controller\EventInterface is not available [ APP/Controller\ErrorController.php , line 54 ]

[ Warning (512)](javascript:void(0);): Unable to emit headers. Headers sent in file=C:\xampp\htdocs\orm\app\vendor\cakephp\cakephp\src\Error\Debugger.php line=831 [ CORE\src\Http\ResponseEmitter.php , line 72 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\orm\app\vendor\cakephp\cakephp\src\Error\Debugger.php:831) [ CORE\src\Http\ResponseEmitter.php , line 169 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\orm\app\vendor\cakephp\cakephp\src\Error\Debugger.php:831) [ CORE\src\Http\ResponseEmitter.php , line 198 ]

[ Warning (2)](javascript:void(0);): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\orm\app\vendor\cakephp\cakephp\src\Error\Debugger.php:831) [ CORE\src\Http\ResponseEmitter.php , line 198 ]

Argument 1 passed to App\Controller\AppController::beforeRender() must be an instance of App\Controller\EventInterface, instance of Cake\Event\Event given, called in C:\xampp\htdocs\orm\app\vendor\cakephp\cakephp\src\Event\EventManager.php on line 310📋

TypeError

You have neglected to add a required use statement at the top of your AppController class. Note how it thinks that your version of beforeRender takes an object of type App\Controller\EventInterface (i.e. in the same namespace as your controller, which is where it assumes things are from by default if you don’t tell it otherwise), while the Cake version takes an object of type Cake\Event\EventInterface. Just put

use Cake\Event\EventInterface;

at the top of your AppController class, and all of these warnings and errors will go away. They have nothing whatsoever to do with the plugin.

1 Like

Hi @Zuluru,

thank you very much. It works now.

BR
Dante

@dantedantas Use this VSCode plugin to have “use” statements auto added for you https://marketplace.visualstudio.com/items?itemName=MehediDracula.php-namespace-resolver.

2 Likes

Hi guys,
i have the same problem. I’ve tried solution suggested by @Zuluru but didn’t works.

In src/Controller/AppController.php I have added this code:

use Cake\Event\EventInterface;

and

public function beforeRender(EventInterface $event)
{
$this->viewBuilder()->setTheme('AdminLTE');
}

I came always with this error:
return [ 'Theme' => [ 'title' => 'MyApp', 'logo' => [ 'mini' => 'MyApp', 'large' => 'MyApp', ], 'login' => [ 'show_remember' => true, 'show_register' => true, 'show_social' => true, ], 'folder' => ROOT, 'skin' => 'blue', ] ];Config file "adminlte.php" did not return an array

I’m using adminLTE 2.0.0, cakePHP 4 and PHP 7.3.

Any ideas?

Thanks…

Has you follow the instructions in https://maiconpinto.github.io/cakephp-adminlte-theme/start

I did it for cakephp 4 and worked fine.
To customize the layout https://github.com/maiconpinto/cakephp-adminlte-theme/wiki/Customize-Layout
and instead of src/Template/Plugin/AdminLTE/Element/.ctp
do templates/plugin/AdminLTE/element/
.php

Hi Hamend,
what version of the AdminLTE had you used?
I tried with the new one and it doesnt work.

Thanks

I was using this one https://github.com/maiconpinto/cakephp-adminlte-theme/wiki/Customize-Layout
Now I am moving to adminLTE 3

Cheers, Hayder Méndez D.

I have tried with AdminLTE 3 without success. Now I am working “manually”.

BR
Dante Dantas

The README.MD is missing the

<?php tag from the first line of config/adminlte.php. Than it becomes an executable script.