From 75b284c8f6fdbe7f69782c693a8849892e434da3 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Tue, 19 Aug 2014 22:06:20 -0700 Subject: [PATCH] Remove Piwik autoloader and replace composer autoloader. --- composer.json | 12 ++ composer.lock | 219 ++++++++++++++++++++------- console | 1 - core/DataTable/Renderer.php | 2 - core/Db/Adapter.php | 3 - core/Loader.php | 126 --------------- core/Plugin/Manager.php | 3 +- core/Tracker.php | 1 - index.php | 2 +- piwik.php | 3 - tests/PHPUnit/bootstrap.php | 1 - tests/PHPUnit/proxy/includes.php | 1 - tests/resources/staticFileServer.php | 2 +- 13 files changed, 181 insertions(+), 195 deletions(-) delete mode 100644 core/Loader.php diff --git a/composer.json b/composer.json index ada86611922..f68897fe60f 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,18 @@ "wiki": "http://dev.piwik.org/", "source": "https://github.com/piwik/piwik" }, + "autoload": { + "psr-4": { + "Piwik\\Plugins\\": "plugins/", + "Piwik\\": "core/" + }, + "psr-0": { + "Zend_": "libs/", + "HTML_": "libs/", + "PEAR_": "libs/", + "Archive_": "libs/" + } + }, "require": { "php": ">=5.3.2", "twig/twig": "1.*", diff --git a/composer.lock b/composer.lock index 257eeb64a42..253e9be71e9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ba9388aa9f61e6a370364aadbf0316ad", + "hash": "b47a13d5f82b7e36891b725fbea836f2", "packages": [ { "name": "leafo/lessphp", @@ -96,16 +96,16 @@ }, { "name": "piwik/device-detector", - "version": "2.3", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/piwik/device-detector.git", - "reference": "c881d3592b55253c4e8968245e7b162f453ca4b9" + "reference": "9cd0338be126aaf947f20fd08a6381c0c658dca5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/piwik/device-detector/zipball/c881d3592b55253c4e8968245e7b162f453ca4b9", - "reference": "c881d3592b55253c4e8968245e7b162f453ca4b9", + "url": "https://api.github.com/repos/piwik/device-detector/zipball/9cd0338be126aaf947f20fd08a6381c0c658dca5", + "reference": "9cd0338be126aaf947f20fd08a6381c0c658dca5", "shasum": "" }, "require": { @@ -123,7 +123,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "GPL-3.0+" + "LGPL-3.0+" ], "authors": [ { @@ -139,21 +139,21 @@ "parser", "useragent" ], - "time": "2014-07-29 10:06:51" + "time": "2014-08-11 20:21:18" }, { "name": "symfony/console", - "version": "v2.5.0", + "version": "v2.5.3", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c" + "reference": "cd2d1e4bac2206b337326b0140ff475fe9ad5f63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c", - "reference": "ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c", + "url": "https://api.github.com/repos/symfony/Console/zipball/cd2d1e4bac2206b337326b0140ff475fe9ad5f63", + "reference": "cd2d1e4bac2206b337326b0140ff475fe9ad5f63", "shasum": "" }, "require": { @@ -183,20 +183,18 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-05-22 08:54:24" + "time": "2014-08-05 09:00:40" }, { "name": "tedivm/jshrink", @@ -241,16 +239,16 @@ }, { "name": "twig/twig", - "version": "v1.15.1", + "version": "v1.16.0", "source": { "type": "git", "url": "https://github.com/fabpot/Twig.git", - "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed" + "reference": "8ce37115802e257a984a82d38254884085060024" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed", - "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/8ce37115802e257a984a82d38254884085060024", + "reference": "8ce37115802e257a984a82d38254884085060024", "shasum": "" }, "require": { @@ -259,7 +257,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.16-dev" } }, "autoload": { @@ -294,22 +292,135 @@ "keywords": [ "templating" ], - "time": "2014-02-13 10:19:29" + "time": "2014-07-05 12:19:05" } ], "packages-dev": [ + { + "name": "ocramius/instantiator", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/Instantiator.git", + "reference": "a7abbb5fc9df6e7126af741dd6c140d1a7369435" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/Instantiator/zipball/a7abbb5fc9df6e7126af741dd6c140d1a7369435", + "reference": "a7abbb5fc9df6e7126af741dd6c140d1a7369435", + "shasum": "" + }, + "require": { + "ocramius/lazy-map": "1.0.*", + "php": "~5.3" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/Ocramius/Instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-08-14 15:10:55" + }, + { + "name": "ocramius/lazy-map", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/LazyMap.git", + "reference": "7fe3d347f5e618bcea7d39345ff83f3651d8b752" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/LazyMap/zipball/7fe3d347f5e618bcea7d39345ff83f3651d8b752", + "reference": "7fe3d347f5e618bcea7d39345ff83f3651d8b752", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "athletic/athletic": "~0.1.6", + "phpmd/phpmd": "1.5.*", + "phpunit/phpunit": ">=3.7", + "satooshi/php-coveralls": "~0.6", + "squizlabs/php_codesniffer": "1.4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "LazyMap\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/", + "role": "Developer" + } + ], + "description": "A library that provides lazy instantiation logic for a map of objects", + "homepage": "https://github.com/Ocramius/LazyMap", + "keywords": [ + "lazy", + "lazy instantiation", + "lazy loading", + "map", + "service location" + ], + "time": "2013-11-09 22:30:54" + }, { "name": "phpunit/php-code-coverage", - "version": "2.0.9", + "version": "2.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ed8ac99ce38c3fd134128c898f7ca74665abef7f" + "reference": "6d196af48e8c100a3ae881940123e693da5a9217" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ed8ac99ce38c3fd134128c898f7ca74665abef7f", - "reference": "ed8ac99ce38c3fd134128c898f7ca74665abef7f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6d196af48e8c100a3ae881940123e693da5a9217", + "reference": "6d196af48e8c100a3ae881940123e693da5a9217", "shasum": "" }, "require": { @@ -361,7 +472,7 @@ "testing", "xunit" ], - "time": "2014-06-29 08:14:40" + "time": "2014-08-06 06:39:42" }, { "name": "phpunit/php-file-iterator", @@ -548,16 +659,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.1.3", + "version": "4.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91" + "reference": "a33fa68ece9f8c68589bfc2da8d2794e27b820bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/939cb801b3b2aa253aedd0b279f40bb8f35cec91", - "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a33fa68ece9f8c68589bfc2da8d2794e27b820bc", + "reference": "a33fa68ece9f8c68589bfc2da8d2794e27b820bc", "shasum": "" }, "require": { @@ -571,7 +682,7 @@ "phpunit/php-file-iterator": "~1.3.1", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "~1.0.2", - "phpunit/phpunit-mock-objects": "~2.1", + "phpunit/phpunit-mock-objects": "~2.2", "sebastian/comparator": "~1.0", "sebastian/diff": "~1.1", "sebastian/environment": "~1.0", @@ -588,7 +699,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1.x-dev" + "dev-master": "4.2.x-dev" } }, "autoload": { @@ -618,28 +729,29 @@ "testing", "xunit" ], - "time": "2014-06-11 14:15:47" + "time": "2014-08-18 05:12:30" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.1.5", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "7878b9c41edb3afab92b85edf5f0981014a2713a" + "reference": "42e589e08bc86e3e9bdf20d385e948347788505b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/7878b9c41edb3afab92b85edf5f0981014a2713a", - "reference": "7878b9c41edb3afab92b85edf5f0981014a2713a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/42e589e08bc86e3e9bdf20d385e948347788505b", + "reference": "42e589e08bc86e3e9bdf20d385e948347788505b", "shasum": "" }, "require": { + "ocramius/instantiator": "~1.0", "php": ">=5.3.3", "phpunit/php-text-template": "~1.2" }, "require-dev": { - "phpunit/phpunit": "~4.1" + "phpunit/phpunit": "4.2.*@dev" }, "suggest": { "ext-soap": "*" @@ -647,7 +759,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "2.2.x-dev" } }, "autoload": { @@ -675,7 +787,7 @@ "mock", "xunit" ], - "time": "2014-06-12 07:22:15" + "time": "2014-08-02 13:50:58" }, { "name": "sebastian/comparator", @@ -946,17 +1058,17 @@ }, { "name": "symfony/yaml", - "version": "v2.5.0", + "version": "v2.5.3", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "b4b09c68ec2f2727574544ef0173684281a5033c" + "reference": "5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/b4b09c68ec2f2727574544ef0173684281a5033c", - "reference": "b4b09c68ec2f2727574544ef0173684281a5033c", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f", + "reference": "5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f", "shasum": "" }, "require": { @@ -978,20 +1090,18 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-05-16 14:25:18" + "time": "2014-08-05 09:00:40" } ], "aliases": [ @@ -1001,6 +1111,7 @@ "stability-flags": [ ], + "prefer-stable": false, "platform": { "php": ">=5.3.2" }, diff --git a/console b/console index bb901dfed78..41b4ec5835a 100755 --- a/console +++ b/console @@ -17,7 +17,6 @@ require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.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'; Piwik\Translate::loadEnglishTranslation(); diff --git a/core/DataTable/Renderer.php b/core/DataTable/Renderer.php index ddcde91cf39..dae970dd5fc 100644 --- a/core/DataTable/Renderer.php +++ b/core/DataTable/Renderer.php @@ -10,7 +10,6 @@ use Exception; use Piwik\DataTable; -use Piwik\Loader; use Piwik\Metrics; use Piwik\Piwik; @@ -168,7 +167,6 @@ public static function factory($name) $className = ucfirst(strtolower($name)); $className = 'Piwik\DataTable\Renderer\\' . $className; try { - Loader::loadClass($className); return new $className; } catch (Exception $e) { $availableRenderers = implode(', ', self::getRenderers()); diff --git a/core/Db/Adapter.php b/core/Db/Adapter.php index 6bafa3a653f..342a320d723 100644 --- a/core/Db/Adapter.php +++ b/core/Db/Adapter.php @@ -8,7 +8,6 @@ */ namespace Piwik\Db; -use Piwik\Loader; use Zend_Db_Table; /** @@ -39,8 +38,6 @@ public static function factory($adapterName, & $dbInfos, $connect = true) } $className = self::getAdapterClassName($adapterName); - Loader::loadClass($className); - $adapter = new $className($dbInfos); if ($connect) { diff --git a/core/Loader.php b/core/Loader.php deleted file mode 100644 index 6e33987f193..00000000000 --- a/core/Loader.php +++ /dev/null @@ -1,126 +0,0 @@ -Tracker['debug']; if ($GLOBALS['PIWIK_TRACKER_DEBUG'] === true) { - require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; - require_once PIWIK_INCLUDE_PATH . '/core/Error.php'; \Piwik\Error::setErrorHandler(); require_once PIWIK_INCLUDE_PATH . '/core/ExceptionHandler.php'; diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index d32c604026d..6a80c72755d 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -33,7 +33,6 @@ require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; require_once PIWIK_INCLUDE_PATH . '/core/FrontController.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/DatabaseTestCase.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php'; diff --git a/tests/PHPUnit/proxy/includes.php b/tests/PHPUnit/proxy/includes.php index 6e3acc8af52..858ae485d20 100644 --- a/tests/PHPUnit/proxy/includes.php +++ b/tests/PHPUnit/proxy/includes.php @@ -13,7 +13,6 @@ ? 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 . '/core/EventDispatcher.php'; require_once PIWIK_INCLUDE_PATH . '/core/Piwik.php'; require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; diff --git a/tests/resources/staticFileServer.php b/tests/resources/staticFileServer.php index 237cf0af59a..5907c169e3e 100644 --- a/tests/resources/staticFileServer.php +++ b/tests/resources/staticFileServer.php @@ -39,7 +39,7 @@ session_cache_limiter('nocache'); @date_default_timezone_set('UTC'); -require_once PIWIK_INCLUDE_PATH .'/core/Loader.php'; +require_once PIWIK_INCLUDE_PATH .'/vendor/autoload.php'; // This is Piwik logo, the static file used in this test suit define("TEST_FILE_LOCATION", dirname(__FILE__) . "/lipsum.txt");