cakephp 4 path error after migrate from 3.9 to 4

22 views Asked by At

I followed the steps to migrate CakePHP 3.9 to 4, the frontend is working fine but the admin is not, which means that I have a /site path and a /site/admin, after checking the logs I've realized that Cake still looking for the admin templates inside the /src folder (only for /admin), but this thing does not happen for the front routes (/site), any clue?

2024-01-09 03:52:34 error: [Cake\View\Exception\MissingElementException] Element file structure/admin/head.php could not be found.

The following paths were searched:

  • /var/www/site/plugins/myplugin/templates/Admin/element/structure/admin/head.php
  • /var/www/site/plugins/myplugin/templates/element/structure/admin/head.php
  • /var/www/site/src/Template/Admin/element/structure/admin/head.php
  • /var/www/site/src/Template/element/structure/admin/head.php
  • /var/www/site/vendor/cakephp/cakephp/templates/Admin/element/structure/admin/head.php
  • /var/www/site/vendor/cakephp/cakephp/templates/element/structure/admin/head.php in /var/www/site/vendor/cakephp/cakephp/src/View/View.php on line 710

I have updated the app.php like this (following the official docu):

return [
    'App' => [
        'encoding' => 'UTF-8',
        'namespace' => 'App',
        'paths' => [
            'plugins' => [ROOT . DS . 'plugins' . DS],
            'templates' => [ROOT . DS . 'templates' . DS],
            'locales' => [RESOURCES . 'locales' . DS],
            // 'templates' => [APP . 'Template' . DS],
            // 'locales' => [APP . 'Locale' . DS],
        ],
    ],
1

There are 1 answers

0
R0bertinski On

Fixed! I did not realise that the plugin configurations need to be updated as well (one by one), which means that the plugin that was failing the "discovery template path process", needs to be updated the same as the app.php (the documentation does not say anything about this concern):

This is working! file: config/sites/myplugin/local.php

  'paths' => [
            // 'plugins' => [ROOT . DS . 'plugins' . DS],
            // 'templates' => [APP . 'Template' . DS],
            // 'locales' => [APP . 'Locale' . DS],
            'plugins' => [ROOT . DS . 'plugins' . DS],
            'templates' => [ROOT . DS . 'templates' . DS],
            'locales' => [RESOURCES . 'locales' . DS],
        ],