контроллер вида модели — класс не найден фатальная ошибка

Я создаю пользовательский MVC фреймворк в PHP на основе учебник Ананта Гарга:

CustomMVC
-app
--controllers
---Controller.php
---HomeController.php
--models
---Home.php
--views
-config
--app.php
-lib
--bootstrap.php
--shared.php
--database.class.php
-public
--.htaccess
--index.php
-tmp
-.htaccess

Мой HomeController не может расширить контроллер, и я получаю следующее:

Неустранимая ошибка: класс ‘app \ controllers \ Controller’ не найден в
/Applications/MAMP/htdocs/CustomMVC/app/controllers/homecontroller.php
на линии 7

Оба они находятся в одном и том же пространстве имен и расположены в одном каталоге. Я не знаю, почему HomeController не может расширить базовый контроллер. Любой совет по этому поводу?

namespace app \ controllers;

controller.php

namespace app\controllers;

use lib\Template;

class Controller {

protected $_model;
protected $_controller;
protected $_action;
protected $_template;

public function __construct($model, $controller, $action) {

$this->_controller = $controller;
$this->_action = $action;
$this->_model = $model;

$this->_model =& new $model;
$this->_template =& new Template($controller,$action);

}

function set($name,$value) {
$this->_template->set($name,$value);
}

function __destruct() {
$this->_template->render();
}
}

HomeController.php

<?php

namespace app\controllers;

use app\controllers;

class HomeController extends Controller {

function getHome($id = null,$name = null) {

}

function getAbout() {

}

function postContact() {

}
}

Это функция автозагрузки в lib ** shared.php **

function __autoload($className) {

if ( file_exists(ROOT . DS . 'lib' . DS . strtolower($className) . '.php') )
{
require_once(ROOT . DS . 'lib' . DS . strtolower($className) . '.php');
}
else if ( file_exists(ROOT . DS . 'lib' . DS . strtolower($className) . '.class.php'))
{
require_once(ROOT . DS . 'lib' . DS . strtolower($className) . '.class.php');
}
else if ( file_exists(ROOT . DS . 'app' . DS . 'controllers' . DS . strtolower($className) . '.php'))
{
require_once(ROOT . DS . 'app' . DS . 'controllers' . DS . strtolower($className) . '.php');
}
else if( file_exists(ROOT . DS . 'app' . DS . 'controllers' . DS . strtolower($className) . '.class.php'))
{
require_once(ROOT . DS . 'app' . DS . 'controllers' . DS . strtolower($className) . '.class.php');
}
else if (file_exists(ROOT . DS . 'app' . DS . 'models' . DS . strtolower($className) . '.php'))
{
require_once(ROOT . DS . 'app' . DS . 'models' . DS . strtolower($className) . '.php');
}
else if (file_exists(ROOT . DS . 'app' . DS . 'models' . DS . strtolower($className) . '.class.php'))
{
require_once(ROOT . DS . 'app' . DS . 'models' . DS . strtolower($className) . '.class.php');
}
else
{
/* Error Generation Code Here */
}
}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector