Skip to content

Commit

Permalink
allow using Piwik when installed as a Composer dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
craue committed Dec 22, 2013
1 parent d9126d4 commit 1ba62b5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion console
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 1 addition & 3 deletions core/testMinimumPhpVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
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() */) {
Expand Down
4 changes: 3 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@

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')) {
Expand Down
4 changes: 3 additions & 1 deletion misc/translationTool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion tests/PHPUnit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
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 );

Expand Down

0 comments on commit 1ba62b5

Please sign in to comment.