Можно изменить среду текущих и дочерних процессов, но не родительского процесса, который породил этот процесс.
I would separate it into your own library, i.e. create the file library/YourApp/Controller/Action.php, and consequently name it YourApp_Controller_Action extends Zend_Controller_Action
. From there you could place controllers where they should be and let them extend YourApp_Controller_Action
in favor of Zend_Controller_Action
.
To find the file you should rely on the autoloader to look not just inside of library/Zend, but also in library/YourApp. I.e. look for the set_include_path
in your bootstrap.
With this technique you should keep in mind that your custom "basecontroller" might get bloated with methods that not all of your controllers needs to inherit.
Настройте автозагрузчик и зарегистрируйте вашу библиотеку, которая должна быть помимо библиотеки Zend, с помощью автозагрузчика, подобного этому (в вашем bootstrap.php после установки пути включения):
//AutoLoad loads classes automatically if they are used
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Mylibrary_');
Затем вы должны переименовать свой BaseController следующим образом
/Zend (folder)
/Mylibrary (folder)
/Controller (folder)
Action.php <-- this is your basecontroller file
, который содержит:
class Mylibrary_Controller_Action extends Zend_Controller_Action
{
}
и ваши обычные контроллеры в папке контроллера:
class IndexController extends Mylibrary_Controller_Action
{
}
поэтому в основном, когда вы хотите расширить структуру, вы сохраняете параллельную структуру в своей собственная библиотека.
Быстрое решение, которое не использует преимущества функции автозагрузки, - это require_once '/path/to/BaseController.php' в файле index-controller.
Если вы настроили автоконтроллер, он не может его найти, поэтому вам следует подумать о том, чтобы проверить, что не так. Попробуйте предыдущий подход и сообщите о результатах.