CakePHP 3: Custom Class Not Found

I just started with CakePHP v3.1.3 yesterday and I move the tiny tiny bits of my CakePHP 2.4.2 site at a time. Mostly just trying to understand the changes. I have a problem with Configure::read().

A little background information. I have SettingsSite , SettingsSiteHeaders and SettingsSitesOptions in my db, I also created corresponding tables for these. In my SettingsSiteTable class I have a method that retrieves the settings stored in the database. Everything is fine, and the following code works in my AppController without any problems.

<?php
namespace App\Controller;

use Cake\Controller\Controller;
use Cake\Event\Event;
use Cake\Core\Configure;

class AppController extends Controller{

    public function beforeFilter(Event $event){
        debug(Configure::read('SettingsSite.title'));
    }

I am having a problem with correctly displaying a value in my view.

, /Default/src/Template/Layout/default.ctp

<title>
    <?php
        echo $this->fetch('title') . ' | ' .
        Configure::read('SettingsSite.title');
    ?>
</title>

Class 'Configure' not found in plugins/Default/src/Template/Layout/default.ctp.

, AppView.php :

use Cake\Core\Configure;

.

+4
3

beforeFilter:)

+3

use Cake\Core\Configure;

+4

On your layout, use the line below. This worked for me:

<?php use Cake\Core\Configure; ?>

<title>
    <?php
        echo $this->fetch('title') . ' | ' .
        Configure::read('SettingsSite.title');
    ?>
</title>
0
source

Source: https://habr.com/ru/post/1613888/


All Articles