/ */ // enable profiling if xhprof is present extension_loaded('xhprof') && xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY); use Zend\Loader\AutoloaderFactory; use Zend\Mvc\Application; define('BASE_PATH', dirname(__DIR__)); // allow DATA_PATH to be overridden via an environment variable define( 'DATA_PATH', getenv('SWARM_DATA_PATH') ? rtrim(getenv('SWARM_DATA_PATH'), '/\\') : BASE_PATH . '/data' ); // sanity check things first sanityCheck(); // setup autoloading set_include_path(BASE_PATH); include 'library/Zend/Loader/AutoloaderFactory.php'; AutoloaderFactory::factory( array( 'Zend\Loader\StandardAutoloader' => array( 'namespaces' => array( 'P4' => BASE_PATH . '/library/P4', 'Record' => BASE_PATH . '/library/Record', 'Zend' => BASE_PATH . '/library/Zend' ) ) ) ); // ensure strict and notice is disabled; otherwise keep the existing levels error_reporting(error_reporting() & ~(E_STRICT|E_NOTICE)); // configure and run the application Application::init( array( 'modules' => array_map( 'basename', array_map('dirname', glob(BASE_PATH . '/module/*/Module.php')) ), 'module_listener_options' => array( 'module_paths' => array(BASE_PATH . '/module'), 'config_glob_paths' => array(DATA_PATH . '/config.php') ), ) )->run(); // do what we can to report what we can detect might be misconfigured function sanityCheck() { $config = DATA_PATH . '/config.php'; // check what could be misconfigured $badPhp = (!defined('PHP_VERSION_ID') || (PHP_VERSION_ID < 50303)); $noP4php = !extension_loaded('perforce'); $noIconv = !extension_loaded('iconv'); $noJson = !extension_loaded('json'); $noSession = !extension_loaded('session'); $numPhpIssues = $badPhp + $noP4php + $noIconv + $noJson + $noSession; $badDataDir = !is_writeable(DATA_PATH); $noConfig = !file_exists($config); $threadSafe = defined('ZEND_THREAD_SAFE') ? ZEND_THREAD_SAFE : false; $numIssues = $numPhpIssues + $badDataDir + $noConfig + $threadSafe; // if anything is misconfigured, compose error page and then die if ($numIssues) { $html = '' . '

Swarm has detected a configuration error

' . '

Problem' . ($numIssues > 1 ? 's' : '') . ' detected:

'; // compose message per condition $html .= ''; // display further information if there were any PHP issues if ($numPhpIssues) { // tell the user where the php.ini file is $php_ini_file = php_ini_loaded_file(); if ($php_ini_file) { $html .= '

The php.ini file loaded is ' . $php_ini_file . '.

'; } else { $html .= '

There is no php.ini loaded (expected to find one in ' . PHP_SYSCONFDIR . ').

'; } // if there are additional php.ini files, list them here if (php_ini_scanned_files()) { $html .= '

Other scanned php.ini files (in ' . PHP_CONFIG_FILE_SCAN_DIR . ') include:

' . ''; } } // wrap it up with links to the docs $html .= '

For more information, please see the' . ' Setting Up documentation;' . ' in particular:

' . '' . '

Please ensure you restart your web server after making any PHP changes.

' . ''; // goodbye cruel world die($html); } }