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.

3 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.

Have you tried override the footer for exemple and creating a footer.php in templates/plugin/AdminLTE/element/? I have tried but that doesnā€™t work. I have tried other location too with no success!

I have found the solution here, in AppController.php we need to add
$this->viewBuilder()->setClassName(ā€˜AdminLTE.AdminLTEā€™);
after
$this->viewBuilder()-setTheme(AdminLTE);

Hi Mokiwaa,

I tried the same thing and it worked for my mac machine when I run php bin/cake.php server.

But I host this code elements are not updating and it is not fetching from the plugins folder :frowning:

anybody have any solution?

Regards,
Ashish

Finally I found the solution.

Ans:

templates/plugin/AdminLTE/element/nav-top.php
templates/plugin/AdminLTE/element/aside-main-sidebar.php
templates/plugin/AdminLTE/element/aside/user-panel.php
templates/plugin/AdminLTE/element/aside/form.php
templates/plugin/AdminLTE/element/aside/sidebar-menu.php
templates/plugin/AdminLTE/element/aside-control-sidebar.php
templates/plugin/AdminLTE/element/footer.php

For me why it was not working because I was using ā€˜Pluginā€™ as a folder name and ā€˜Elementā€™ as a folder name where it should be in lower case only.

Regards,
Ashish