Bootstrapping Zend Framework 1.x with composer namespaces
<?php | |
/** | |
* Bootstrap the App in an annonymous function preserving global namespace. | |
*/ | |
call_user_func(function(){ | |
// Define path to application directory | |
defined('APPLICATION_PATH') | |
|| define('APPLICATION_PATH', | |
realpath(dirname(__FILE__) . '/../application')); | |
// Define application environment | |
defined('APPLICATION_ENV') | |
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? | |
getenv('APPLICATION_ENV') : 'production')); | |
/* Use the namespaces in composer to create an include that that zend can | |
* Safely. | |
*/ | |
$paths = array_merge( | |
array( | |
get_include_path(), | |
realpath(APPLICATION_PATH . '/../library'), | |
), | |
include dirname(APPLICATION_PATH) . | |
'/vendor/composer/autoload_namespaces.php' | |
); | |
foreach ($paths as $key => $path) { | |
if(is_array($path)){ | |
foreach ($path as $p){ | |
array_unshift($paths, $p); | |
} | |
unset($paths[$key]); | |
} | |
} | |
set_include_path(implode(PATH_SEPARATOR, $paths)); | |
/** Zend_Application */ | |
require_once 'Zend/Application.php'; | |
require_once dirname(APPLICATION_PATH) . '/vendor/autoload.php'; | |
// Create application, bootstrap, and run | |
$application = new Zend_Application( | |
APPLICATION_ENV, | |
APPLICATION_PATH . '/configs/application.ini' | |
); | |
$application->bootstrap() | |
->run(); | |
}); |
This comment has been minimized.
This comment has been minimized.
@Seldaek thanks for the heads up on this I wasn't aware of the change, just found the discussion from a few days ago on the google group. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Please migrate to vendor/composer/autoload_namespaces.php and vendor/autoload.php - the .composer dir is there only for BC these days and will be removed at some point.