I have a standard php site in work, which suddenly was to be joined onto a zend site. Wtf. Anyway.

Create a file zend_init.php and require that in your header.

<?php
// Define path to application directory
defined('APPLICATION_PATH')
 || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application/'));
 //die(APPLICATION_PATH);
// Define application environment
defined('APPLICATION_ENV')
 || define('APPLICATION_ENV', 'development');
 
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
 realpath(APPLICATION_PATH . '/../library'),
 get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
 APPLICATION_ENV,
 APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();

That’s it! Just edit the path to find where your application folder is.

Now without having to do any require_once() or include() commands, we can simply just call a new object like you would in your mvc app!

Advertisements