# CakePHP 4 with AdminLTE

**URL:** <https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773>\
**Category:** Need Help\
**Created:** [May 3, 2020, 12:52am UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773 "2020-05-03T00:52:39Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![dantedantas](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dantedantas/32/1770_2.png) [@dantedantas](https://discourse.cakephp.org/u/dantedantas)\
**Post date:** [May 3, 2020, 12:52am UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/1 "2020-05-03T00:52:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jubbs](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@Jubbs](https://discourse.cakephp.org/u/Jubbs)\
**Post date:** [May 3, 2020, 9:43pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/2 "2020-05-03T21:43:58Z")

</div>

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

It says it compatible with version 4.

---

<div class="post-metadata">

**Author:** ![dantedantas](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dantedantas/32/1770_2.png) [@dantedantas](https://discourse.cakephp.org/u/dantedantas)\
**Post date:** [May 3, 2020, 11:28pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/3 "2020-05-03T23:28:45Z")

</div>

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:

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/0/03dec8ade662f47737d4a53a7a89c299a7981353.png)

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

---

<div class="post-metadata">

**Author:** ![dantedantas](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dantedantas/32/1770_2.png) [@dantedantas](https://discourse.cakephp.org/u/dantedantas)\
**Post date:** [May 3, 2020, 11:42pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/4 "2020-05-03T23:42:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [May 4, 2020, 4:17am UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/5 "2020-05-04T04:17:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dantedantas](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dantedantas/32/1770_2.png) [@dantedantas](https://discourse.cakephp.org/u/dantedantas)\
**Post date:** [May 4, 2020, 1:05pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/6 "2020-05-04T13:05:59Z")

</div>

Hi @Zuluru,

thank you very much. It works now.

BR  
Dante

---

<div class="post-metadata">

**Author:** ![ADmad](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/admad/32/20_2.png) [@ADmad](https://discourse.cakephp.org/u/ADmad)\
**Post date:** [May 9, 2020, 7:21pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/7 "2020-05-09T19:21:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fabriziodilello](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/fabriziodilello/32/1968_2.png) [@fabriziodilello](https://discourse.cakephp.org/u/fabriziodilello)\
**Post date:** [August 18, 2020, 1:12pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/8 "2020-08-18T13:12:58Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![hamend](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hamend](https://discourse.cakephp.org/u/hamend)\
**Post date:** [August 26, 2020, 11:58pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/9 "2020-08-26T23:58:45Z")

</div>

Has you follow the instructions in [https://maiconpinto.github.io/cakephp-adminlte-theme/start](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](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

---

<div class="post-metadata">

**Author:** ![dantedantas](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dantedantas/32/1770_2.png) [@dantedantas](https://discourse.cakephp.org/u/dantedantas)\
**Post date:** [August 27, 2020, 7:08am UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/10 "2020-08-27T07:08:27Z")

</div>

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

Thanks

---

<div class="post-metadata">

**Author:** ![hamend](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hamend](https://discourse.cakephp.org/u/hamend)\
**Post date:** [September 1, 2020, 10:30pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/11 "2020-09-01T22:30:36Z")

</div>

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

Cheers, Hayder Méndez D.

---

<div class="post-metadata">

**Author:** ![dantedantas](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dantedantas/32/1770_2.png) [@dantedantas](https://discourse.cakephp.org/u/dantedantas)\
**Post date:** [September 2, 2020, 10:23am UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/12 "2020-09-02T10:23:21Z")

</div>

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

BR  
Dante Dantas

---

<div class="post-metadata">

**Author:** ![ptorok](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@ptorok](https://discourse.cakephp.org/u/ptorok)\
**Post date:** [September 9, 2020, 7:23pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/13 "2020-09-09T19:23:59Z")

</div>

The README.MD is missing the

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

---

<div class="post-metadata">

**Author:** ![mokiwaa](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mokiwaa](https://discourse.cakephp.org/u/mokiwaa)\
**Post date:** [October 6, 2020, 3:43am UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/14 "2020-10-06T03:43:36Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![mokiwaa](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mokiwaa](https://discourse.cakephp.org/u/mokiwaa)\
**Post date:** [October 6, 2020, 3:54am UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/15 "2020-10-06T03:54:37Z")

</div>

I have found the solution [here](https://github.com/maiconpinto/cakephp-adminlte-theme/issues/107), in AppController.php we need to add  
$this-\>viewBuilder()-\>setClassName(‘AdminLTE.AdminLTE’);  
after  
$this-\>viewBuilder()-setTheme(AdminLTE);

---

<div class="post-metadata">

**Author:** ![ashish\_onmobile](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/ashish_onmobile/32/460_2.png) [@ashish\_onmobile](https://discourse.cakephp.org/u/ashish_onmobile)\
**Post date:** [January 6, 2021, 10:07pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/16 "2021-01-06T22:07:17Z")

</div>

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 ☹

anybody have any solution?

Regards,  
Ashish

---

<div class="post-metadata">

**Author:** ![ashish\_onmobile](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/ashish_onmobile/32/460_2.png) [@ashish\_onmobile](https://discourse.cakephp.org/u/ashish_onmobile)\
**Post date:** [January 6, 2021, 10:13pm UTC](https://discourse.cakephp.org/t/cakephp-4-with-adminlte/7773/17 "2021-01-06T22:13:37Z")

</div>

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

> <https://stackoverflow.com/questions/63174722/change-the-path-search-order/63180817#63180817>

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
