Skip to content

Instantly share code, notes, and snippets.

@zircote

zircote/index.php

Created Apr 28, 2012
Embed
What would you like to do?
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();
});
@Seldaek

This comment has been minimized.

Copy link

@Seldaek Seldaek commented Apr 29, 2012

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.

@zircote

This comment has been minimized.

Copy link
Owner Author

@zircote zircote commented Apr 29, 2012

@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
You can’t perform that action at this time.