diff options
author | Christian Raue <christian.raue@gmail.com> | 2013-12-22 14:15:50 +0400 |
---|---|---|
committer | Christian Raue <christian.raue@gmail.com> | 2013-12-22 14:15:50 +0400 |
commit | 1ba62b546d0cf54fac121428f7f3e603f1509a2f (patch) | |
tree | 5932640a0bf56ddbfbc69b0ac48adb37fc564969 | |
parent | d9126d4398b090e6f07728b3eec1b3c0a6060ea2 (diff) |
allow using Piwik when installed as a Composer dependency
-rwxr-xr-x | console | 4 | ||||
-rw-r--r-- | core/testMinimumPhpVersion.php | 4 | ||||
-rw-r--r-- | index.php | 4 | ||||
-rw-r--r-- | misc/translationTool.sh | 4 | ||||
-rw-r--r-- | tests/PHPUnit/bootstrap.php | 4 |
5 files changed, 13 insertions, 7 deletions
@@ -5,7 +5,9 @@ define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; -require_once PIWIK_INCLUDE_PATH . '/vendor/autoload.php'; +require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') + ? PIWIK_INCLUDE_PATH . '/vendor/autoload.php' // Piwik is the main project + : PIWIK_INCLUDE_PATH . '/../../autoload.php'; // Piwik is installed as a dependency require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; diff --git a/core/testMinimumPhpVersion.php b/core/testMinimumPhpVersion.php index e7dd79fd04..7e58e23404 100644 --- a/core/testMinimumPhpVersion.php +++ b/core/testMinimumPhpVersion.php @@ -46,9 +46,7 @@ if ($minimumPhpInvalid) { To enjoy Piwik, you need remove <pre>ini_set</pre> from your <pre>disable_functions</pre> directive in php.ini, and restart your webserver.</p>"; } - $autoloadPath = '/vendor/autoload.php'; - $autoloader = PIWIK_INCLUDE_PATH . $autoloadPath; - if (!file_exists($autoloader)) { + if (!file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') && !file_exists(PIWIK_INCLUDE_PATH . '/../../autoload.php')) { $composerInstall = "In the piwik directory, run in the command line the following (eg. via ssh): \n\n" . "<pre> curl -sS https://getcomposer.org/installer | php \n\n php composer.phar install\n\n</pre> "; if (DIRECTORY_SEPARATOR === '\\' /* ::isWindows() */) { @@ -38,7 +38,9 @@ require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; session_cache_limiter('nocache'); @date_default_timezone_set('UTC'); -require_once PIWIK_INCLUDE_PATH . '/vendor/autoload.php'; +require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') + ? PIWIK_INCLUDE_PATH . '/vendor/autoload.php' // Piwik is the main project + : PIWIK_INCLUDE_PATH . '/../../autoload.php'; // Piwik is installed as a dependency require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; if(!defined('PIWIK_PRINT_ERROR_BACKTRACE')) { diff --git a/misc/translationTool.sh b/misc/translationTool.sh index f6bda85521..5fb7671d8b 100644 --- a/misc/translationTool.sh +++ b/misc/translationTool.sh @@ -290,7 +290,9 @@ function setTranslationsForLanguage() { require_once PIWIK_INCLUDE_PATH . "/libs/upgradephp/upgrade.php"; require_once PIWIK_INCLUDE_PATH . "/core/Loader.php"; - require_once PIWIK_INCLUDE_PATH . "/vendor/autoload.php"; + require_once file_exists(PIWIK_INCLUDE_PATH . "/vendor/autoload.php") + ? PIWIK_INCLUDE_PATH . "/vendor/autoload.php" // Piwik is the main project + : PIWIK_INCLUDE_PATH . "/../../autoload.php"; // Piwik is installed as a dependency use Piwik\Translate\Writer; use Piwik\Translate\Validate\NoScripts; diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index 6d6f69dca5..5a7d925035 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -40,7 +40,9 @@ require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/UITest.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/FakeAccess.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockPiwikOption.php'; -require_once PIWIK_INCLUDE_PATH . '/vendor/autoload.php'; +require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') + ? PIWIK_INCLUDE_PATH . '/vendor/autoload.php' // Piwik is the main project + : PIWIK_INCLUDE_PATH . '/../../autoload.php'; // Piwik is installed as a dependency \Piwik\Profiler::setupProfilerXHProf( $mainRun = true ); |