From fbf34f16ab5526669dae5b7eb130aac0803e3aed Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 18 Mar 2012 00:48:30 -0400 Subject: [feature/event-dispatcher] Implement configurable autoloader selection. The code is in startup.php which should be used by all scripts. PHPBB3-9550 --- phpBB/includes/startup.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpBB/includes/startup.php') diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 2100fbd97e..de55db2960 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -146,5 +146,26 @@ if (function_exists('date_default_timezone_set') && function_exists('date_defaul date_default_timezone_set(@date_default_timezone_get()); } +// Autoloading of dependencies. +// Three options are supported: +// 1. Specify PHPBB_AUTOLOAD=/path/to/autoload.php in the environment. +// This is useful for running CLI scripts and tests. +// /path/to/autoload.php should define and register class loaders +// for all of phpBB's dependencies. +// 2. If dependencies are installed with Composer, Composer will create a +// vendor/.composer/autoload.php. If this file exists it will be +// automatically used by phpBB. +// 3. Failing that phpBB assumes that autoloading has been set up in +// some other way. This might be useful in cases when phpBB is integrated +// into a larger program. +if (getenv('PHPBB_AUTOLOAD')) +{ + require(getenv('PHPBB_AUTOLOAD')); +} +else if (file_exists($phpbb_root_path . 'vendor/.composer/autoload.php')) +{ + require($phpbb_root_path . 'vendor/.composer/autoload.php'); +} + $starttime = explode(' ', microtime()); $starttime = $starttime[1] + $starttime[0]; -- cgit v1.2.1 From a44423baee5d0d5e0fd8899204a71e4a292dc6bf Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 24 Mar 2012 21:37:45 +0100 Subject: [feature/event-dispatcher] Change composer autoloading options Check if composer's generated autoloader is present, and if not give an error. PHPBB3-9550 --- phpBB/includes/startup.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'phpBB/includes/startup.php') diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 9c4e1374ba..45eaff6fc7 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -149,22 +149,32 @@ if (function_exists('date_default_timezone_set') && function_exists('date_defaul // Autoloading of dependencies. // Three options are supported: -// 1. Specify PHPBB_AUTOLOAD=/path/to/autoload.php in the environment. -// This is useful for running CLI scripts and tests. +// 1. If dependencies are installed with Composer, Composer will create a +// vendor/.composer/autoload.php. If this file exists it will be +// automatically used by phpBB. This is the default mode that phpBB +// will use when shipped. +// 2. To disable composer autoloading, PHPBB_NO_AUTOLOAD can be specified. +// Additionally specify PHPBB_AUTOLOAD=/path/to/autoload.php in the +// environment. This is useful for running CLI scripts and tests. // /path/to/autoload.php should define and register class loaders // for all of phpBB's dependencies. -// 2. If dependencies are installed with Composer, Composer will create a -// vendor/.composer/autoload.php. If this file exists it will be -// automatically used by phpBB. -// 3. Failing that phpBB assumes that autoloading has been set up in -// some other way. This might be useful in cases when phpBB is integrated -// into a larger program. -if (getenv('PHPBB_AUTOLOAD')) +// 3. You can also set PHPBB_NO_AUTOLOAD without setting PHPBB_AUTOLOAD. +// In this case autoloading needs to be defined before running any phpBB +// script. This might be useful in cases when phpBB is integrated into a +// larger program. +if (getenv('PHPBB_NO_AUTOLOAD')) { - require(getenv('PHPBB_AUTOLOAD')); + if (getenv('PHPBB_AUTOLOAD')) + { + require(getenv('PHPBB_AUTOLOAD')); + } } -else if (file_exists($phpbb_root_path . 'vendor/.composer/autoload.php')) +else { + if (!file_exists($phpbb_root_path . 'vendor/.composer/autoload.php')) + { + trigger_error('You have not set up composer dependencies. See http://getcomposer.org/.', E_USER_ERROR); + } require($phpbb_root_path . 'vendor/.composer/autoload.php'); } -- cgit v1.2.1 From 138e7dae0087e683fcb170df1e806b8e4f4b86cd Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 28 Mar 2012 21:48:46 +0200 Subject: [feature/event-dispatcher] Rename PHPBB_NO_AUTOLOAD=>PHPBB_NO_COMPOSER_AUTOLOAD PHPBB3-9550 --- phpBB/includes/startup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/startup.php') diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 45eaff6fc7..f75d70e366 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -153,16 +153,16 @@ if (function_exists('date_default_timezone_set') && function_exists('date_defaul // vendor/.composer/autoload.php. If this file exists it will be // automatically used by phpBB. This is the default mode that phpBB // will use when shipped. -// 2. To disable composer autoloading, PHPBB_NO_AUTOLOAD can be specified. +// 2. To disable composer autoloading, PHPBB_NO_COMPOSER_AUTOLOAD can be specified. // Additionally specify PHPBB_AUTOLOAD=/path/to/autoload.php in the // environment. This is useful for running CLI scripts and tests. // /path/to/autoload.php should define and register class loaders // for all of phpBB's dependencies. -// 3. You can also set PHPBB_NO_AUTOLOAD without setting PHPBB_AUTOLOAD. +// 3. You can also set PHPBB_NO_COMPOSER_AUTOLOAD without setting PHPBB_AUTOLOAD. // In this case autoloading needs to be defined before running any phpBB // script. This might be useful in cases when phpBB is integrated into a // larger program. -if (getenv('PHPBB_NO_AUTOLOAD')) +if (getenv('PHPBB_NO_COMPOSER_AUTOLOAD')) { if (getenv('PHPBB_AUTOLOAD')) { -- cgit v1.2.1