diff --git a/.gitignore b/.gitignore index 7068f6680..604cbb31b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /app/config/local.php /app/tmp/cache/* /app/tmp/logs/* +/app/tmp/templates/* /docs/changelog.md /docs/cache/ /docs/*/cache/ diff --git a/README.md b/README.md index 8d8966197..a9c0a7da9 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Copyright Matomo team. Do not republish, or copy, or distribute this code or con ```bash $ cd app/ $ composer install +$ mkdir tmp/cache +$ mkdir tmp/templates $ cd public/ $ php -S 0.0.0.0:8000 ``` diff --git a/app/composer.json b/app/composer.json index 4a38a23d8..2a9acacff 100644 --- a/app/composer.json +++ b/app/composer.json @@ -5,15 +5,14 @@ } }, "require": { - "php": ">=5.4.0", - "twig/twig": "1.12.*", - "slim/slim": "2.*", - "slim/extras": "2.*", - "slim/views": "0.1.*", - "michelf/php-markdown": "1.4.1", - "mnapoli/front-yaml": "~1.2" + "php": ">=7.2.0", + "slim/slim": "4.*", + "michelf/php-markdown": "1.9.0", + "mnapoli/front-yaml": "~1.2", + "slim/psr7": "^1.0", + "slim/twig-view": "3.0.0", + "php-di/php-di": "^6.0", + "ext-json": "*" }, - "require-dev": { - "phpunit/phpunit": "~4.0" - } + "require-dev": {} } diff --git a/app/composer.lock b/app/composer.lock index 44ffe4200..e9bdc2203 100644 --- a/app/composer.lock +++ b/app/composer.lock @@ -1,25 +1,32 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "6870489ca88cfd2310ec6abde337b371", + "content-hash": "798d0ab193746c04bb70e01a65476970", "packages": [ { "name": "erusev/parsedown", - "version": "1.1.2", + "version": "1.7.4", "source": { "type": "git", "url": "https://github.com/erusev/parsedown.git", - "reference": "9816507a75b27b61035671cd2fc6f524a9b4c25c" + "reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/erusev/parsedown/zipball/9816507a75b27b61035671cd2fc6f524a9b4c25c", - "reference": "9816507a75b27b61035671cd2fc6f524a9b4c25c", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/cb17b6477dfff935958ba01325f2e8a2bfa6dab3", + "reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3", "shasum": "" }, + "require": { + "ext-mbstring": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35" + }, "type": "library", "autoload": { "psr-0": { @@ -43,34 +50,140 @@ "markdown", "parser" ], - "time": "2014-11-19 18:18:56" + "time": "2019-12-30T22:54:17+00:00" }, { - "name": "michelf/php-markdown", - "version": "1.4.1", + "name": "fig/http-message-util", + "version": "1.1.3", "source": { "type": "git", - "url": "https://github.com/michelf/php-markdown.git", - "reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6" + "url": "https://github.com/php-fig/http-message-util.git", + "reference": "35b19404371b31b3a43823c755398c48c9966db4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/de9a19c7bf352d41cc99ed86c3c0ef17e87394b6", - "reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6", + "url": "https://api.github.com/repos/php-fig/http-message-util/zipball/35b19404371b31b3a43823c755398c48c9966db4", + "reference": "35b19404371b31b3a43823c755398c48c9966db4", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": "^5.3 || ^7.0", + "psr/http-message": "^1.0" }, "type": "library", "extra": { "branch-alias": { - "dev-lib": "1.4.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { - "psr-0": { - "Michelf": "" + "psr-4": { + "Fig\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Utility classes and constants for use with PSR-7 (psr/http-message)", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2018-11-19T16:19:58+00:00" + }, + { + "name": "jeremeamia/superclosure", + "version": "2.4.0", + "source": { + "type": "git", + "url": "https://github.com/jeremeamia/super_closure.git", + "reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/5707d5821b30b9a07acfb4d76949784aaa0e9ce9", + "reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^1.2|^2.0|^3.0|^4.0", + "php": ">=5.4", + "symfony/polyfill-php56": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0|^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-4": { + "SuperClosure\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia", + "role": "Developer" + } + ], + "description": "Serialize Closure objects, including their context and binding", + "homepage": "https://github.com/jeremeamia/super_closure", + "keywords": [ + "closure", + "function", + "lambda", + "parser", + "serializable", + "serialize", + "tokenizer" + ], + "time": "2018-03-21T22:21:57+00:00" + }, + { + "name": "michelf/php-markdown", + "version": "1.9.0", + "source": { + "type": "git", + "url": "https://github.com/michelf/php-markdown.git", + "reference": "c83178d49e372ca967d1a8c77ae4e051b3a3c75c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/michelf/php-markdown/zipball/c83178d49e372ca967d1a8c77ae4e051b3a3c75c", + "reference": "c83178d49e372ca967d1a8c77ae4e051b3a3c75c", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4.3 <5.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Michelf\\": "Michelf/" } }, "notification-url": "https://packagist.org/downloads/", @@ -81,41 +194,43 @@ { "name": "Michel Fortin", "email": "michel.fortin@michelf.ca", - "homepage": "http://michelf.ca/", + "homepage": "https://michelf.ca/", "role": "Developer" }, { "name": "John Gruber", - "homepage": "http://daringfireball.net/" + "homepage": "https://daringfireball.net/" } ], "description": "PHP Markdown", - "homepage": "http://michelf.ca/projects/php-markdown/", + "homepage": "https://michelf.ca/projects/php-markdown/", "keywords": [ "markdown" ], - "time": "2014-05-05 02:43:50" + "time": "2019-12-02T02:32:27+00:00" }, { "name": "mnapoli/front-yaml", - "version": "1.2.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/mnapoli/FrontYAML.git", - "reference": "6c99f04051c8cae9e7ce0d45b9a821ffc01a71d2" + "reference": "24070ace8b741247bb3161cbb38ecc541268b296" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mnapoli/FrontYAML/zipball/6c99f04051c8cae9e7ce0d45b9a821ffc01a71d2", - "reference": "6c99f04051c8cae9e7ce0d45b9a821ffc01a71d2", + "url": "https://api.github.com/repos/mnapoli/FrontYAML/zipball/24070ace8b741247bb3161cbb38ecc541268b296", + "reference": "24070ace8b741247bb3161cbb38ecc541268b296", "shasum": "" }, "require": { "erusev/parsedown": "~1.0", - "symfony/yaml": "~2.1" + "php": ">=5.4.0", + "symfony/yaml": "~2.1|^3.0|^4.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "league/commonmark": "~0.7", + "phpunit/phpunit": "~4.5" }, "type": "library", "autoload": { @@ -127,186 +242,275 @@ "license": [ "MIT" ], - "time": "2014-11-23 22:43:08" + "time": "2017-10-29T19:29:55+00:00" }, { - "name": "slim/extras", - "version": "2.0.3", - "target-dir": "Slim/Extras", + "name": "nikic/fast-route", + "version": "v1.3.0", "source": { "type": "git", - "url": "https://github.com/codeguy/Slim-Extras.git", - "reference": "a022ed23dae94e164000acd891e3394d903f9623" + "url": "https://github.com/nikic/FastRoute.git", + "reference": "181d480e08d9476e61381e04a71b34dc0432e812" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/codeguy/Slim-Extras/zipball/a022ed23dae94e164000acd891e3394d903f9623", - "reference": "a022ed23dae94e164000acd891e3394d903f9623", + "url": "https://api.github.com/repos/nikic/FastRoute/zipball/181d480e08d9476e61381e04a71b34dc0432e812", + "reference": "181d480e08d9476e61381e04a71b34dc0432e812", "shasum": "" }, "require": { - "php": ">=5.3.0", - "slim/slim": ">=2.0.0" + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|~5.7" }, "type": "library", "autoload": { - "psr-0": { - "Twig_Extensions_": "Views/Extension/", - "Slim\\Extras": "." - } + "psr-4": { + "FastRoute\\": "src/" + }, + "files": [ + "src/functions.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Andrew Smith", - "email": "a.smith@silentworks.co.uk", - "homepage": "http://thoughts.silentworks.co.uk/" - }, - { - "name": "Josh Lockhart", - "email": "info@joshlockhart.com", - "homepage": "http://www.joshlockhart.com/" + "name": "Nikita Popov", + "email": "nikic@php.net" } ], - "description": "Extras package for the Slim Framework", - "homepage": "http://github.com/codeguy/Slim-Extras", + "description": "Fast request router for PHP", "keywords": [ - "extensions", - "middleware", - "templating" + "router", + "routing" ], - "time": "2013-01-07 17:56:10" + "time": "2018-02-13T20:26:39+00:00" }, { - "name": "slim/slim", - "version": "2.4.3", + "name": "nikic/php-parser", + "version": "v4.3.0", "source": { "type": "git", - "url": "https://github.com/codeguy/Slim.git", - "reference": "4906b77a07c7bd6ff1a99aea903e940a2d4fa106" + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "9a9981c347c5c49d6dfe5cf826bb882b824080dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/codeguy/Slim/zipball/4906b77a07c7bd6ff1a99aea903e940a2d4fa106", - "reference": "4906b77a07c7bd6ff1a99aea903e940a2d4fa106", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/9a9981c347c5c49d6dfe5cf826bb882b824080dc", + "reference": "9a9981c347c5c49d6dfe5cf826bb882b824080dc", "shasum": "" }, "require": { - "php": ">=5.3.0" + "ext-tokenizer": "*", + "php": ">=7.0" }, - "suggest": { - "ext-mcrypt": "Required for HTTP cookie encryption" + "require-dev": { + "ircmaxell/php-yacc": "0.0.5", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0" }, + "bin": [ + "bin/php-parse" + ], "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3-dev" + } + }, "autoload": { - "psr-0": { - "Slim": "." + "psr-4": { + "PhpParser\\": "lib/PhpParser" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Josh Lockhart", - "email": "info@joshlockhart.com", - "homepage": "http://www.joshlockhart.com/" + "name": "Nikita Popov" } ], - "description": "Slim Framework, a PHP micro framework", - "homepage": "http://github.com/codeguy/Slim", + "description": "A PHP parser written in PHP", "keywords": [ - "microframework", - "rest", - "router" + "parser", + "php" ], - "time": "2014-04-05 18:33:59" + "time": "2019-11-08T13:50:10+00:00" }, { - "name": "slim/views", - "version": "0.1.2", - "target-dir": "Slim/Views", + "name": "php-di/invoker", + "version": "2.0.0", "source": { "type": "git", - "url": "https://github.com/codeguy/Slim-Views.git", - "reference": "f0a05ea0b654218e40de692ed7cddcad1cf4b828" + "url": "https://github.com/PHP-DI/Invoker.git", + "reference": "540c27c86f663e20fe39a24cd72fa76cdb21d41a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/codeguy/Slim-Views/zipball/f0a05ea0b654218e40de692ed7cddcad1cf4b828", - "reference": "f0a05ea0b654218e40de692ed7cddcad1cf4b828", + "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/540c27c86f663e20fe39a24cd72fa76cdb21d41a", + "reference": "540c27c86f663e20fe39a24cd72fa76cdb21d41a", "shasum": "" }, "require": { - "php": ">=5.3.0", - "slim/slim": ">=2.4.0" + "psr/container": "~1.0" }, - "suggest": { - "smarty/smarty": "Smarty templating system", - "twig/twig": "Twig templating system" + "require-dev": { + "athletic/athletic": "~0.1.8", + "phpunit/phpunit": "~4.5" }, "type": "library", "autoload": { - "psr-0": { - "Slim\\Views": "" + "psr-4": { + "Invoker\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Andrew Smith", - "email": "a.smith@silentworks.co.uk", - "homepage": "http://www.silentworks.co.uk/" + "description": "Generic and extensible callable invoker", + "homepage": "https://github.com/PHP-DI/Invoker", + "keywords": [ + "callable", + "dependency", + "dependency-injection", + "injection", + "invoke", + "invoker" + ], + "time": "2017-03-20T19:28:22+00:00" + }, + { + "name": "php-di/php-di", + "version": "6.0.11", + "source": { + "type": "git", + "url": "https://github.com/PHP-DI/PHP-DI.git", + "reference": "9bdcc2f41f5fb700ddd01bc4fa8d5bd7b3f94620" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/9bdcc2f41f5fb700ddd01bc4fa8d5bd7b3f94620", + "reference": "9bdcc2f41f5fb700ddd01bc4fa8d5bd7b3f94620", + "shasum": "" + }, + "require": { + "jeremeamia/superclosure": "^2.0", + "nikic/php-parser": "^2.0|^3.0|^4.0", + "php": ">=7.0.0", + "php-di/invoker": "^2.0", + "php-di/phpdoc-reader": "^2.0.1", + "psr/container": "^1.0" + }, + "provide": { + "psr/container-implementation": "^1.0" + }, + "require-dev": { + "doctrine/annotations": "~1.2", + "friendsofphp/php-cs-fixer": "^2.4", + "mnapoli/phpunit-easymock": "~1.0", + "ocramius/proxy-manager": "~2.0.2", + "phpstan/phpstan": "^0.9.2", + "phpunit/phpunit": "~6.4" + }, + "suggest": { + "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)", + "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~2.0)" + }, + "type": "library", + "autoload": { + "psr-4": { + "DI\\": "src/" }, - { - "name": "Josh Lockhart", - "email": "info@joshlockhart.com", - "homepage": "http://www.joshlockhart.com/" + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The dependency injection container for humans", + "homepage": "http://php-di.org/", + "keywords": [ + "PSR-11", + "container", + "container-interop", + "dependency injection", + "di", + "ioc", + "psr11" + ], + "time": "2019-12-12T07:58:02+00:00" + }, + { + "name": "php-di/phpdoc-reader", + "version": "2.1.1", + "source": { + "type": "git", + "url": "https://github.com/PHP-DI/PhpDocReader.git", + "reference": "15678f7451c020226807f520efb867ad26fbbfcf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/15678f7451c020226807f520efb867ad26fbbfcf", + "reference": "15678f7451c020226807f520efb867ad26fbbfcf", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.6" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpDocReader\\": "src/PhpDocReader" } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" ], - "description": "Smarty and Twig View Parser package for the Slim Framework", - "homepage": "http://github.com/codeguy/Slim-Views", + "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)", "keywords": [ - "extensions", - "slimphp", - "templating" + "phpdoc", + "reflection" ], - "time": "2014-04-03 16:31:10" + "time": "2019-09-26T11:24:58+00:00" }, { - "name": "symfony/yaml", - "version": "v2.5.7", - "target-dir": "Symfony/Component/Yaml", + "name": "psr/container", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "900d38bc8f74a50343ce65dd1c1e9819658ee56b" + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/900d38bc8f74a50343ce65dd1c1e9819658ee56b", - "reference": "900d38bc8f74a50343ce65dd1c1e9819658ee56b", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" + "psr-4": { + "Psr\\Container\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -315,92 +519,89 @@ ], "authors": [ { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2014-11-20 13:22:25" + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" }, { - "name": "twig/twig", - "version": "v1.12.3", + "name": "psr/http-factory", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/fabpot/Twig.git", - "reference": "27f3428b08c7f656d6824359a9d9dee3f5fce31b" + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/27f3428b08c7f656d6824359a9d9dee3f5fce31b", - "reference": "27f3428b08c7f656d6824359a9d9dee3f5fce31b", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", "shasum": "" }, "require": { - "php": ">=5.2.4" + "php": ">=7.0.0", + "psr/http-message": "^1.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { - "psr-0": { - "Twig_": "lib/" + "psr-4": { + "Psr\\Http\\Message\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3" + "MIT" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", + "description": "Common interfaces for PSR-7 HTTP message factories", "keywords": [ - "templating" - ], - "time": "2013-04-08 12:40:11" - } - ], - "packages-dev": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "time": "2019-04-30T12:38:16+00:00" + }, { - "name": "doctrine/instantiator", - "version": "1.0.4", + "name": "psr/http-message", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "2.0.*@ALPHA" + "php": ">=5.3.0" }, "type": "library", "extra": { @@ -409,8 +610,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\Instantiator\\": "src" + "psr-4": { + "Psr\\Http\\Message\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -419,645 +620,710 @@ ], "authors": [ { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", "keywords": [ - "constructor", - "instantiate" - ], - "time": "2014-10-13 12:58:55" + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" }, { - "name": "phpunit/php-code-coverage", - "version": "2.0.11", + "name": "psr/http-server-handler", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7" + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7", - "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "~1.0", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4.1" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" + "php": ">=7.0", + "psr/http-message": "^1.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "description": "Common interface for HTTP server-side request handler", "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2014-08-31 06:33:04" + "handler", + "http", + "http-interop", + "psr", + "psr-15", + "psr-7", + "request", + "response", + "server" + ], + "time": "2018-10-30T16:46:14+00:00" }, { - "name": "phpunit/php-file-iterator", - "version": "1.3.4", + "name": "psr/http-server-middleware", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { - "classmap": [ - "File/" - ] + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "description": "Common interface for HTTP server-side middleware", "keywords": [ - "filesystem", - "iterator" + "http", + "http-interop", + "middleware", + "psr", + "psr-15", + "psr-7", + "request", + "response" ], - "time": "2013-10-10 15:34:57" + "time": "2018-10-30T17:12:04+00:00" }, { - "name": "phpunit/php-text-template", - "version": "1.2.0", + "name": "ralouphie/getallheaders", + "version": "3.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" }, "type": "library", "autoload": { - "classmap": [ - "Text/" + "files": [ + "src/getallheaders.php" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" } ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2014-01-30 17:20:04" + "description": "A polyfill for getallheaders.", + "time": "2019-03-08T08:55:37+00:00" }, { - "name": "phpunit/php-timer", - "version": "1.0.5", + "name": "slim/psr7", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + "url": "https://github.com/slimphp/Slim-Psr7.git", + "reference": "7ca5b5d96687b7c563238715cc80b12675d8b895" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "url": "https://api.github.com/repos/slimphp/Slim-Psr7/zipball/7ca5b5d96687b7c563238715cc80b12675d8b895", + "reference": "7ca5b5d96687b7c563238715cc80b12675d8b895", "shasum": "" }, "require": { - "php": ">=5.3.3" + "fig/http-message-util": "^1.1.2", + "php": "^7.2", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "adriansuter/php-autoload-override": "^1.0", + "ext-json": "*", + "http-interop/http-factory-tests": "^0.6.0", + "php-http/psr7-integration-tests": "dev-master", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^8.5", + "squizlabs/php_codesniffer": "^3.5" }, "type": "library", "autoload": { - "classmap": [ - "PHP/" - ] + "psr-4": { + "Slim\\Psr7\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Josh Lockhart", + "email": "hello@joshlockhart.com", + "homepage": "http://joshlockhart.com" + }, + { + "name": "Andrew Smith", + "email": "a.smith@silentworks.co.uk", + "homepage": "http://silentworks.co.uk" + }, + { + "name": "Rob Allen", + "email": "rob@akrabat.com", + "homepage": "http://akrabat.com" + }, + { + "name": "Pierre Berube", + "email": "pierre@lgse.com", + "homepage": "http://www.lgse.com" } ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", + "description": "Strict PSR-7 implementation", + "homepage": "https://www.slimframework.com", "keywords": [ - "timer" + "http", + "psr-7", + "psr7" ], - "time": "2013-08-02 07:42:54" + "time": "2020-01-04T23:05:43+00:00" }, { - "name": "phpunit/php-token-stream", - "version": "1.3.0", + "name": "slim/slim", + "version": "4.4.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "f8d5d08c56de5cfd592b3340424a81733259a876" + "url": "https://github.com/slimphp/Slim.git", + "reference": "207acac048652a35d4762a737d59e317aedc02df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876", - "reference": "f8d5d08c56de5cfd592b3340424a81733259a876", + "url": "https://api.github.com/repos/slimphp/Slim/zipball/207acac048652a35d4762a737d59e317aedc02df", + "reference": "207acac048652a35d4762a737d59e317aedc02df", "shasum": "" }, "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" + "ext-json": "*", + "nikic/fast-route": "^1.3", + "php": "^7.2", + "psr/container": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0", + "psr/http-server-middleware": "^1.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "adriansuter/php-autoload-override": "^1.0", + "ext-simplexml": "*", + "guzzlehttp/psr7": "^1.5", + "http-interop/http-factory-guzzle": "^1.0", + "laminas/laminas-diactoros": "^2.1", + "nyholm/psr7": "^1.1", + "nyholm/psr7-server": "^0.3.0", + "phpspec/prophecy": "^1.10", + "phpstan/phpstan": "^0.11.5", + "phpunit/phpunit": "^8.5", + "slim/http": "^0.7", + "slim/psr7": "^0.3", + "squizlabs/php_codesniffer": "^3.5" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } + "suggest": { + "ext-simplexml": "Needed to support XML format in BodyParsingMiddleware", + "ext-xml": "Needed to support XML format in BodyParsingMiddleware", + "php-di/php-di": "PHP-DI is the recommended container library to be used with Slim", + "slim/psr7": "Slim PSR-7 implementation. See https://www.slimframework.com/docs/v4/start/installation.html for more information." }, + "type": "library", "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Slim\\": "Slim" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "name": "Josh Lockhart", + "email": "hello@joshlockhart.com", + "homepage": "https://joshlockhart.com" + }, + { + "name": "Andrew Smith", + "email": "a.smith@silentworks.co.uk", + "homepage": "http://silentworks.co.uk" + }, + { + "name": "Rob Allen", + "email": "rob@akrabat.com", + "homepage": "http://akrabat.com" + }, + { + "name": "Pierre Berube", + "email": "pierre@lgse.com", + "homepage": "http://www.lgse.com" + }, + { + "name": "Gabriel Manricks", + "email": "gmanricks@me.com", + "homepage": "http://gabrielmanricks.com" } ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs", + "homepage": "https://www.slimframework.com", "keywords": [ - "tokenizer" + "api", + "framework", + "micro", + "router" ], - "time": "2014-08-31 06:12:13" + "time": "2020-01-05T03:51:47+00:00" }, { - "name": "phpunit/phpunit", - "version": "4.3.5", + "name": "slim/twig-view", + "version": "3.0.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1" + "url": "https://github.com/slimphp/Twig-View.git", + "reference": "46bc497bada017c24e6736f80af1baa8c6cc71d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2dab9d593997db4abcf58d0daf798eb4e9cecfe1", - "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1", + "url": "https://api.github.com/repos/slimphp/Twig-View/zipball/46bc497bada017c24e6736f80af1baa8c6cc71d3", + "reference": "46bc497bada017c24e6736f80af1baa8c6cc71d3", "shasum": "" }, "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpunit/php-code-coverage": "~2.0", - "phpunit/php-file-iterator": "~1.3.2", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "~1.0.2", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.0", - "sebastian/diff": "~1.1", - "sebastian/environment": "~1.0", - "sebastian/exporter": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.0" + "php": "^7.1", + "psr/http-message": "^1.0", + "slim/slim": "^4.0", + "twig/twig": "^2.8|^3.0" }, - "suggest": { - "phpunit/php-invoker": "~1.1" + "require-dev": { + "phpstan/phpstan": "^0.11.15", + "phpunit/phpunit": "^7.5", + "psr/http-factory": "^1.0", + "squizlabs/php_codesniffer": "^3.4.2" }, - "bin": [ - "phpunit" - ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.3.x-dev" - } - }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Slim\\Views\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "", - "../../symfony/yaml/" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Josh Lockhart", + "email": "hello@joshlockhart.com", + "homepage": "http://joshlockhart.com" + }, + { + "name": "Pierre Berube", + "email": "pierre@lgse.com", + "homepage": "http://www.lgse.com" } ], - "description": "The PHP Unit Testing framework.", - "homepage": "http://www.phpunit.de/", + "description": "Slim Framework 4 view helper built on top of the Twig (2 and 3) templating component", + "homepage": "https://www.slimframework.com", "keywords": [ - "phpunit", - "testing", - "xunit" + "framework", + "slim", + "template", + "twig", + "view" ], - "time": "2014-11-11 10:11:09" + "time": "2019-12-02T23:40:24+00:00" }, { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.0", + "name": "symfony/polyfill-ctype", + "version": "v1.13.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "c63d2367247365f688544f0d500af90a11a44c65" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", - "reference": "c63d2367247365f688544f0d500af90a11a44c65", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", "shasum": "" }, "require": { - "doctrine/instantiator": "~1.0,>=1.0.1", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.3" + "php": ">=5.3.3" }, "suggest": { - "ext-soap": "*" + "ext-ctype": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "1.13-dev" } }, "autoload": { - "classmap": [ - "src/" + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", "keywords": [ - "mock", - "xunit" + "compatibility", + "ctype", + "polyfill", + "portable" ], - "time": "2014-10-03 05:12:11" + "time": "2019-11-27T13:56:44+00:00" }, { - "name": "sebastian/comparator", - "version": "1.0.1", + "name": "symfony/polyfill-mbstring", + "version": "v1.13.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef" + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", - "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.1", - "sebastian/exporter": "~1.0" + "php": ">=5.3.3" }, - "require-dev": { - "phpunit/phpunit": "~4.1" + "suggest": { + "ext-mbstring": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.13-dev" } }, "autoload": { - "classmap": [ - "src/" + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", "keywords": [ - "comparator", - "compare", - "equality" + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" ], - "time": "2014-05-11 23:00:21" + "time": "2019-11-27T14:18:11+00:00" }, { - "name": "sebastian/diff", - "version": "1.2.0", + "name": "symfony/polyfill-php56", + "version": "v1.13.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" + "url": "https://github.com/symfony/polyfill-php56.git", + "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/53dd1cdf3cb986893ccf2b96665b25b3abb384f4", + "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4", "shasum": "" }, "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" + "php": ">=5.3.3", + "symfony/polyfill-util": "~1.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.13-dev" } }, "autoload": { - "classmap": [ - "src/" + "psr-4": { + "Symfony\\Polyfill\\Php56\\": "" + }, + "files": [ + "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", + "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", + "homepage": "https://symfony.com", "keywords": [ - "diff" + "compatibility", + "polyfill", + "portable", + "shim" ], - "time": "2014-08-15 10:29:00" + "time": "2019-11-27T13:56:44+00:00" }, { - "name": "sebastian/environment", - "version": "1.2.0", + "name": "symfony/polyfill-util", + "version": "v1.13.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d" + "url": "https://github.com/symfony/polyfill-util.git", + "reference": "964a67f293b66b95883a5ed918a65354fcd2258f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d", - "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/964a67f293b66b95883a5ed918a65354fcd2258f", + "reference": "964a67f293b66b95883a5ed918a65354fcd2258f", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "require-dev": { - "phpunit/phpunit": "~4.3" - }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.13-dev" } }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Symfony\\Polyfill\\Util\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", + "description": "Symfony utilities for portability of PHP codes", + "homepage": "https://symfony.com", "keywords": [ - "Xdebug", - "environment", - "hhvm" + "compat", + "compatibility", + "polyfill", + "shim" ], - "time": "2014-10-22 06:38:05" + "time": "2019-11-27T13:56:44+00:00" }, { - "name": "sebastian/exporter", - "version": "1.0.2", + "name": "symfony/yaml", + "version": "v4.4.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0" + "url": "https://github.com/symfony/yaml.git", + "reference": "cd014e425b3668220adb865f53bff64b3ad21767" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", - "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", + "url": "https://api.github.com/repos/symfony/yaml/zipball/cd014e425b3668220adb865f53bff64b3ad21767", + "reference": "cd014e425b3668220adb865f53bff64b3ad21767", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "symfony/console": "^3.4|^4.0|^5.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "4.4-dev" } }, "autoload": { - "classmap": [ - "src/" + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { - "name": "Adam Harvey", - "email": "aharvey@php.net" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2014-09-10 00:51:36" + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2020-01-21T11:12:16+00:00" }, { - "name": "sebastian/version", - "version": "1.0.3", + "name": "twig/twig", + "version": "v3.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43" + "url": "https://github.com/twigphp/Twig.git", + "reference": "28f856a4c57eeb24485916e8a68403f41a133616" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", - "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/28f856a4c57eeb24485916e8a68403f41a133616", + "reference": "28f856a4c57eeb24485916e8a68403f41a133616", "shasum": "" }, + "require": { + "php": "^7.2.5", + "symfony/polyfill-ctype": "^1.8", + "symfony/polyfill-mbstring": "^1.3" + }, + "require-dev": { + "psr/container": "^1.0", + "symfony/phpunit-bridge": "^4.4|^5.0" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Twig\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1065,22 +1331,38 @@ ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Twig Team", + "role": "Contributors" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" } ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2014-03-07 15:35:33" + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "https://twig.symfony.com", + "keywords": [ + "templating" + ], + "time": "2019-12-28T07:17:28+00:00" } ], + "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, + "prefer-lowest": false, "platform": { - "php": ">=5.4.0" + "php": ">=7.2.0", + "ext-json": "*" }, "platform-dev": [] } diff --git a/app/helpers/Cache.php b/app/helpers/Cache.php index 0b27659f4..072a75755 100644 --- a/app/helpers/Cache.php +++ b/app/helpers/Cache.php @@ -11,21 +11,22 @@ class Cache { private static $folder = '../tmp/cache'; + private static $TwigCacheFolder = '../tmp/templates'; public static function get($key) { if (!static::isEnabled()) { - return; + return false; } if (empty($key)) { - return; + return false; } $file = static::getPathToCacheFile($key); if (!file_exists($file)) { - return; + return false; } $content = file_get_contents($file); @@ -34,6 +35,7 @@ public static function get($key) return $content; } + return false; } public static function set($key, $content) @@ -70,6 +72,11 @@ public static function invalidate() static::unlinkRecursive(static::$folder); } + public static function invalidate_Twig_Cache() + { + static::unlinkRecursive(static::$TwigCacheFolder); + } + private static function unlinkRecursive($dir) { if (!$dh = @opendir($dir)) { diff --git a/app/helpers/CacheMiddleware.php b/app/helpers/CacheMiddleware.php index 629f62f78..376efe018 100644 --- a/app/helpers/CacheMiddleware.php +++ b/app/helpers/CacheMiddleware.php @@ -8,6 +8,10 @@ namespace helpers; +use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface as RequestHandler; +use Slim\Psr7\Response; + /** * Class CacheMiddleware. * @@ -16,30 +20,31 @@ * * @package helpers */ -class CacheMiddleware extends \Slim\Middleware +class CacheMiddleware { - public function call() + public function __invoke(Request $request, RequestHandler $handler): Response { - /** @var $req \Slim\Http\Request */ - $req = $this->app->request; - /** @var $res \Slim\Http\Response */ - $res = $this->app->response; - - if ($this->shouldCache($req)) { - $content = Cache::get($this->getCacheKey($req)); + if ($this->shouldCache($request)) { + $content = Cache::get($this->getCacheKey($request)); + $response = new Response(); if (!empty($content)) { - $res->setBody($content); - - return; + if ($this->isJsonData($request)) { + $response = $response->withHeader('Content-Type', 'application/json'); + $response->getBody()->write($content); + } else { + $response->getBody()->write($content . "\n"); + } + return $response; } } - $this->next->call(); - - if ($this->shouldCache($req) && 200 == $res->getStatus()) { - Cache::set($this->getCacheKey($req), $res->getBody()); + $response = $handler->handle($request); + $content = $response->getBody(); + if ($this->shouldCache($request) && 200 == $response->getStatusCode() && !$this->hadIncludeFileError($content)) { + Cache::set($this->getCacheKey($request), $content); } + return $response; } /** @@ -64,15 +69,33 @@ private function pathToCacheKey($path) return $path; } - private function shouldCache($req) + private function hadIncludeFileError($content) + { + return strpos($content, "Error while retrieving") !== false; + } + + private function isJsonData(Request $req) { - return $req->isGet(); + return substr($req->getUri()->getPath(), 0, 6) === '/data/'; } - private function getCacheKey($req) + + private function shouldCache(Request $req) + { + return $req->getMethod() == "GET"; + } + + private function getCacheKey(Request $req) { $piwikVersion = Environment::getPiwikVersion(); - return $piwikVersion . '_' . $this->pathToCacheKey($req->getPath()); + + if ($this->isJsonData($req)) { + $type = "json"; + } else { + $type = "html"; + } + + return $piwikVersion . '_' . $this->pathToCacheKey($req->getUri()->getPath()) . "." . $type; } } \ No newline at end of file diff --git a/app/helpers/Log.php b/app/helpers/Log.php deleted file mode 100644 index 31a92308f..000000000 --- a/app/helpers/Log.php +++ /dev/null @@ -1,66 +0,0 @@ -$level($message); - } - } - - private static function getLog() - { - if (!empty(static::$log)) { - return static::$log; - } - - if (Slim::getInstance()) { - - return Slim::getInstance()->getLog(); - } - } -} \ No newline at end of file diff --git a/app/helpers/PiwikVersionMiddleware.php b/app/helpers/MatomoVersionMiddleware.php similarity index 69% rename from app/helpers/PiwikVersionMiddleware.php rename to app/helpers/MatomoVersionMiddleware.php index e6c3686cd..d13334c16 100644 --- a/app/helpers/PiwikVersionMiddleware.php +++ b/app/helpers/MatomoVersionMiddleware.php @@ -8,39 +8,36 @@ namespace helpers; -/** - * Class CacheMiddleware. - * - * Only GET requests are cached so far and only by path. So if you request a URL like "/foo" and URL like "/foo?bar=1" - * the same cache key is used. - * - * @package helpers - */ -class PiwikVersionMiddleware extends \Slim\Middleware -{ - public function call() - { - /** @var $environment \Slim\Environment */ +use Psr\Http\Message\ResponseInterface as Response; +use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface as RequestHandler; - $environment = $this->app->environment; +class MatomoVersionMiddleware +{ + public function __invoke(Request $request, RequestHandler $handler): Response + { + $uri = $request->getUri(); + $path = $uri->getPath(); // we match eg /2.x or /3.x /19.x and remove it from the path so our routes in routes/page.php still match. // Instead of changing the path I wanted to add a group around all routes in page but slim 2 doesn't allow us to define // a condition on a group route unfortunately $matches = array(); - if ($this->hasPiwikVersionInUrl($environment['PATH_INFO'], $matches)) { + if ($this->hasPiwikVersionInUrl($path, $matches)) { if ($this->isValidPiwikVersionAndAllowedToBeInPath($matches[1])) { // we only allow usage of 2.x or 3.x for outdated Piwik versions. Latest will be always // available only under "/" whereas older versions will be /2.x . Once Piwik 4 is available, // it will automatically work for '/2.x' and '/3.x', we only need to increase LATEST_PIWIK_DOCS_VERSION // in the config Environment::setPiwikVersion($matches[1]); - $environment['PATH_INFO'] = $this->removePiwikVersionFromCurrentPath($environment['PATH_INFO'], $matches[1]); + $uri = $uri->withPath($this->removePiwikVersionFromCurrentPath($path, $matches[1])); + $request = $request->withUri($uri); } } + $response = $handler->handle($request); - $this->next->call(); + return $response; } private function removePiwikVersionFromCurrentPath($path, $piwikVersion) diff --git a/app/helpers/Twig.php b/app/helpers/Twig.php index 79104a747..290776a07 100755 --- a/app/helpers/Twig.php +++ b/app/helpers/Twig.php @@ -7,9 +7,11 @@ */ namespace helpers; +use Twig\TwigFilter; + class Twig { - public static function registerFilter(\Twig_Environment $environment) + public static function registerFilter(\Twig\Environment $environment) { $environment->addFilter(static::getCompleteUrlFilter()); $environment->addFilter(static::getCompleteUrlForPiwikVersionFilter()); @@ -17,14 +19,14 @@ public static function registerFilter(\Twig_Environment $environment) private static function getCompleteUrlFilter() { - return new \Twig_SimpleFilter('completeUrl', function ($value) { + return new TwigFilter('completeUrl', function ($value) { return Environment::completeUrl($value); }); } private static function getCompleteUrlForPiwikVersionFilter() { - return new \Twig_SimpleFilter('completeUrlForPiwikVersion', function ($value, $piwikVersion) { + return new TwigFilter('completeUrlForPiwikVersion', function ($value, $piwikVersion) { $currentPiwikVersion = Environment::getPiwikVersion(); diff --git a/app/helpers/Url.php b/app/helpers/Url.php new file mode 100644 index 000000000..8ad22feb4 --- /dev/null +++ b/app/helpers/Url.php @@ -0,0 +1,87 @@ +getMenuUrl()); + } catch (DocumentNotExistException $e) { + } + } + } + + if (empty($url)) { + if (strpos($path, '/api-reference/') !== false) { + + try { + $replaced = str_replace('/api-reference/', '', $path); + // we check if the requested resource maybe exists for another Piwik version + $guide = new ApiReferenceGuide($replaced); + $url = Environment::completeUrl($guide->getMenuUrl()); + } catch (DocumentNotExistException $e) { + } + + try { + $replaced = str_replace('/api-reference/', '', $path); + // we check if the requested resource maybe exists for another Piwik version + $phpdoc = new PhpDoc($replaced, $replaced); + $url = Environment::completeUrl($phpdoc->getMenuUrl()); + } catch (DocumentNotExistException $e) { + } + } + } + + if (empty($url)) { + /** @var \helpers\Content\MenuItem[] $categories */ + $categories = [ + new IntegrateCategory(), + new DevelopCategory(), + new DesignCategory(), + new ApiReferenceCategory(), + new DevelopInDepthCategory() + ]; + + foreach ($categories as $category) { + if ($path === $category->getMenuUrl()) { + $url = $path; + break; + } + } + } + + Environment::setPiwikVersion($currentPiwikVersion); + + return $url; + } +} \ No newline at end of file diff --git a/app/public/index.php b/app/public/index.php index 28b2afcdd..05b16b9dd 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -6,49 +6,76 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use DI\Container; +use helpers\CacheMiddleware; +use helpers\Environment; +use helpers\Git; +use helpers\MatomoVersionMiddleware; +use helpers\Url; +use Psr\Http\Message\ServerRequestInterface; +use Slim\Exception\HttpNotFoundException; +use Slim\Factory\AppFactory; +use Slim\Middleware\ContentLengthMiddleware; +use Slim\Psr7\Response; +use Slim\Views\Twig; + require '../vendor/autoload.php'; if (file_exists('../config/local.php')) { require '../config/local.php'; } require '../config/app.php'; -use Slim\Slim; -use Slim\Views\Twig as Twig; -use helpers\Log; -use helpers\CacheMiddleware; -use helpers\PiwikVersionMiddleware; date_default_timezone_set("UTC"); -$twig = new Twig(); - -// New Slim App -$app = new Slim(array( - 'view' => $twig, - 'log.enabled' => true, - 'debug' => DEBUG, - 'templates.path' => '../templates', - 'templates.cache' => realpath('../tmp/templates'), - 'templates.charset' => 'utf-8', - 'templates.auto_reload' => true, - 'templates.autoescape' => true, - 'log.writer' => new \Slim\Extras\Log\DateTimeFileWriter( - array('path' => realpath('../tmp/logs'), 'name_format' => 'Y-m-d') - ) -)); -$app->add(new PiwikVersionMiddleware()); -$app->add(new CacheMiddleware()); -$app->error(function (\Exception $e) use ($app) { - Log::error('An unhandled exception occurred: ' . $e->getMessage() . $e->getTraceAsString()); +// Create Container +$container = new Container(); +AppFactory::setContainer($container); - $app->response()->status(500); +// Set view in Container +$container->set('view', function () { + $view = Twig::create('../templates', ['cache' => '../tmp/templates']); + $view->getEnvironment()->addGlobal('urlIfAvailableInNewerVersion', false); + $view->getEnvironment()->addGlobal('availablePiwikVersions', Environment::getAvailablePiwikVersions()); + $view->getEnvironment()->addGlobal('selectedPiwikVersion', Environment::getPiwikVersion()); + $view->getEnvironment()->addGlobal('latestPiwikDocsVersion', LATEST_PIWIK_DOCS_VERSION); + $view->getEnvironment()->addGlobal('revision', Git::getCurrentShortRevision()); + return $view; }); -$app->setName('developer.matomo.org'); -$log = $app->getLog(); -$log->setEnabled(true); +$app = AppFactory::create(); + +helpers\Twig::registerFilter($container->get("view")->getEnvironment()); + +$app->add(new MatomoVersionMiddleware()); +$app->add(new CacheMiddleware()); + +$routeCollector = $app->getRouteCollector(); +$routeCollector->setCacheFile('../tmp/cache/route_cache.php'); + +$contentLengthMiddleware = new ContentLengthMiddleware(); +$app->add($contentLengthMiddleware); + +$errorMiddleware = $app->addErrorMiddleware(DEBUG, true, true); +$errorMiddleware->setErrorHandler( + HttpNotFoundException::class, + function (ServerRequestInterface $request, Throwable $exception, bool $displayErrorDetails) { + $response = new Response(); + -helpers\Twig::registerFilter($app->view->getInstance()); + $alternativeUrls = array(); + foreach (Environment::getAvailablePiwikVersions() as $piwikVersion) { + if ($piwikVersion != Environment::getPiwikVersion()) { + $url = Url::getUrlIfDocumentIsAvailableInPiwikVersion($request->getUri()->getPath(), $piwikVersion); + if (!empty($url)) { + $alternativeUrls[] = $url; + } + } + } + return $this->get("view")->render($response->withStatus(404), '404.twig', [ + "alternativeUrls" => $alternativeUrls + ]); + }); require '../routes/page.php'; diff --git a/app/public/js/app.js b/app/public/js/app.js index 27a79aa16..67cd12ef8 100644 --- a/app/public/js/app.js +++ b/app/public/js/app.js @@ -33,7 +33,7 @@ $quickSearchTypeahead.typeahead({ var url = $quickSearchTypeahead.attr('data-action'); $.get(url, {}, function (data) { - quickSearchData = JSON.parse(data); + quickSearchData = data; process(quickSearchData.names); }); } diff --git a/app/routes/page.php b/app/routes/page.php index 279f7eee1..48388be1b 100644 --- a/app/routes/page.php +++ b/app/routes/page.php @@ -6,276 +6,151 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use helpers\Cache; use helpers\Content\ApiReferenceGuide; +use helpers\Content\Category\ApiReferenceCategory; use helpers\Content\Category\Category; use helpers\Content\Category\CategoryList; use helpers\Content\Category\ChangelogCategory; use helpers\Content\Category\DesignCategory; use helpers\Content\Category\DevelopCategory; use helpers\Content\Category\DevelopInDepthCategory; -use helpers\Content\Guide; -use helpers\Content\PhpDoc; use helpers\Content\Category\IntegrateCategory; -use helpers\Content\Category\ApiReferenceCategory; -use helpers\Redirects; -use helpers\SearchIndex; use helpers\Content\Category\SupportCategory; +use helpers\Content\Guide; +use helpers\Content\PhpDoc; use helpers\DocumentNotExistException; -use helpers\Git; use helpers\Environment; -use Slim\Slim; - -function send404NotFound(Slim $app) { - $app->pass(); -} - -function initView($app) -{ - $app->hook('slim.before.dispatch', function () use ($app) { - $app->view->setData('urlIfAvailableInNewerVersion', false); - $availableVersions = Environment::getAvailablePiwikVersions(); - - if (!Environment::isLatestPiwikVersion()) { - $matomoVersion = Environment::getPiwikVersion(); - $alternativeUrl = getUrlIfDocumentIsAvailableInPiwikVersion($app, LATEST_PIWIK_DOCS_VERSION); - - if (in_array($matomoVersion, $availableVersions)) { - $app->view->setData('urlIfAvailableInNewerVersion', $alternativeUrl); - } else { - // redirect to newest version - //$app->response->redirect($alternativeUrl, 301); - // exit; - $app->view->setData('urlIfAvailableInNewerVersion', $alternativeUrl); - } - } +use helpers\Redirects; +use helpers\SearchIndex; +use helpers\Url; +use Psr\Http\Message\ResponseInterface as Response; +use Psr\Http\Message\ServerRequestInterface as Request; - $app->view->setData('availablePiwikVersions', $availableVersions); - $app->view->setData('selectedPiwikVersion', Environment::getPiwikVersion()); - $app->view->setData('latestPiwikDocsVersion', LATEST_PIWIK_DOCS_VERSION); - $app->view->setData('revision', Git::getCurrentShortRevision()); - $app->view->setData('currentPath', $app->request->getPathInfo()); - }); -} -function renderGuide(Slim $app, Guide $guide, Category $category) +function renderGuide(Slim\Views\Twig $view, Response $response, Psr\Http\Message\UriInterface $uri, Guide $guide, Category $category) { - $app->render('guide.twig', [ - 'category' => $category, - 'guide' => $guide, + return $view->render($response, 'guide.twig', [ + 'category' => $category, + 'guide' => $guide, 'linkToEditDocument' => $guide->linkToEdit(), - 'activeMenu' => $category->getName(), + 'activeMenu' => $category->getName(), + 'currentPath' => $uri->getPath(), + 'urlIfAvailableInNewerVersion' => (Environment::isLatestPiwikVersion() ? false : Url::getUrlIfDocumentIsAvailableInPiwikVersion($uri->getPath(), LATEST_PIWIK_DOCS_VERSION)) ]); } -initView($app); - -function getUrlIfDocumentIsAvailableInPiwikVersion($app, $piwikVersion) -{ - $currentPiwikVersion = Environment::getPiwikVersion(); - - // we now work in context of that piwik version - Environment::setPiwikVersion($piwikVersion); - - $path = $app->request->getPath(); - $url = ''; - - if ($path === '/' || $path === '') { - $url = '/'; - } - if (empty($url)) { - if (strpos($path, '/guides/') !== false) { - try { - // we check if the requested resource maybe exists for another Piwik version - $guide = new Guide(str_replace('/guides/', '', $path)); - $url = Environment::completeUrl($guide->getMenuUrl()); - } catch (DocumentNotExistException $e) {} - } - } - - if (empty($url)) { - if (strpos($path, '/api-reference/') !== false) { - - try { - $replaced = str_replace('/api-reference/', '', $path); - // we check if the requested resource maybe exists for another Piwik version - $guide = new ApiReferenceGuide( $replaced ); - $url = Environment::completeUrl($guide->getMenuUrl()); - } catch (DocumentNotExistException $e) { - } - - try { - $replaced = str_replace('/api-reference/', '', $path); - // we check if the requested resource maybe exists for another Piwik version - $phpdoc = new PhpDoc($replaced, $replaced); - $url = Environment::completeUrl($phpdoc->getMenuUrl()); - } catch (DocumentNotExistException $e) { - } - } - } - - if (empty($url)) { - /** @var \helpers\Content\MenuItem[] $categories */ - $categories = [ - new IntegrateCategory(), - new DevelopCategory(), - new DesignCategory(), - new ApiReferenceCategory(), - new DevelopInDepthCategory() - ]; - - foreach ($categories as $category) { - if ($path === $category->getMenuUrl() ) { - $url = $path; - break; - } - } - } - - Environment::setPiwikVersion($currentPiwikVersion); - - return $url; -} - -$app->notFound(function () use ($app) { - $alternativeUrls = array(); - foreach (Environment::getAvailablePiwikVersions() as $piwikVersion) { - if ($piwikVersion != Environment::getPiwikVersion()) { - $url = getUrlIfDocumentIsAvailableInPiwikVersion($app, $piwikVersion); - if (!empty($url)) { - $alternativeUrls[] = $url; - } - } - } - $app->view->setData('alternativeUrls', $alternativeUrls); - - $app->render('404.twig'); -}); // Redirects foreach (Redirects::getRedirects() as $url => $redirect) { - $app->get($url, function () use ($app, $redirect) { - $app->redirect($redirect, 301); + $app->get($url, function (Request $request, Response $response, $args) use ($redirect) { + return $response->withStatus(301)->withHeader('Location', $redirect); }); } -$app->get('(/)', function () use ($app) { - $app->render('home.twig', ['isHome' => true]); + +$app->get('/', function (Request $request, Response $response, $args) { + return $this->get("view")->render($response, 'home.twig', ['isHome' => true]); }); -$app->get('/guides/:name1/:name2(/)', function ($name1, $name2) use ($app) { +$app->get('/guides/{name1}/{name2}', function (Request $request, Response $response, $args) { try { - $guide = new Guide($name1 . '/' . $name2); + $guide = new Guide($args["name1"] . '/' . $args["name2"]); } catch (DocumentNotExistException $e) { - send404NotFound($app); - return; + throw new \Slim\Exception\HttpNotFoundException($request, $response); } $category = CategoryList::getCategory($guide->getCategory()); - renderGuide($app, $guide, $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $guide, $category); }); -$app->get('/guides/:name(/)', function ($name) use ($app) { +$app->get('/guides/{name}', function (Request $request, Response $response, $args) { try { - $guide = new Guide($name); + $guide = new Guide($args["name"]); } catch (DocumentNotExistException $e) { - send404NotFound($app); - return; + throw new \Slim\Exception\HttpNotFoundException($request, $response); } $category = CategoryList::getCategory($guide->getCategory()); - renderGuide($app, $guide, $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $guide, $category); }); -$app->get('/integration', function () use ($app) { + +$app->get('/integration', function (Request $request, Response $response, $args) { $category = new IntegrateCategory(); - renderGuide($app, $category->getIntroGuide(), $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $category->getIntroGuide(), $category); }); -$app->get('/design', function () use ($app) { +$app->get('/design', function (Request $request, Response $response, $args) { $category = new DesignCategory(); - renderGuide($app, $category->getIntroGuide(), $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $category->getIntroGuide(), $category); }); -$app->get('/develop', function () use ($app) { +$app->get('/develop', function (Request $request, Response $response, $args) { $category = new DevelopCategory(); - renderGuide($app, $category->getIntroGuide(), $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $category->getIntroGuide(), $category); }); -$app->get('/piwik-in-depth', function () use ($app) { +$app->get('/piwik-in-depth', function (Request $request, Response $response, $args) { $category = new DevelopInDepthCategory(); - renderGuide($app, $category->getIntroGuide(), $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $category->getIntroGuide(), $category); }); -$app->get('/api-reference/Piwik/:names+', function ($names) use ($app) { - if (! ctype_alnum(implode('', $names))) { - send404NotFound($app); - return; + +$app->get('/api-reference/Piwik/[{params:.*}]', function (Request $request, Response $response, $args) { + $paramArray = explode("/", $request->getAttribute('params')); + if (!ctype_alnum(implode('', $paramArray))) { + throw new \Slim\Exception\HttpNotFoundException($request, $response); } - $names = array_filter($names); - $file = 'Piwik/' . implode('/', $names); + $file = 'Piwik/' . $request->getAttribute('params'); try { $doc = new PhpDoc($file, $file); } catch (DocumentNotExistException $e) { - send404NotFound($app); - return; + throw new \Slim\Exception\HttpNotFoundException($request, $response); } - - renderGuide($app, $doc, new ApiReferenceCategory()); + return renderGuide($this->get("view"), $response, $request->getUri(), $doc, new ApiReferenceCategory()); }); -$app->get('/api-reference/classes', function () use ($app) { - renderGuide($app, new PhpDoc('Classes', 'classes'), new ApiReferenceCategory()); +$app->get('/api-reference/classes', function (Request $request, Response $response, $args) { + return renderGuide($this->get("view"), $response, $request->getUri(), new PhpDoc('Classes', 'classes'), new ApiReferenceCategory()); }); -$app->get('/api-reference/events', function () use ($app) { - renderGuide($app, new PhpDoc('Hooks', 'events'), new ApiReferenceCategory()); -}); -$app->get('/api-reference/index', function () use ($app) { - renderGuide($app, new PhpDoc('Index', 'index'), new ApiReferenceCategory()); -}); -$app->get('/api-reference/PHP-Piwik-Tracker', function () use ($app) { - renderGuide($app, new PhpDoc('PiwikTracker', 'PHP-Piwik-Tracker'), new ApiReferenceCategory()); +$app->get('/api-reference/events', function (Request $request, Response $response, $args) { + return renderGuide($this->get("view"), $response, $request->getUri(), new PhpDoc('Hooks', 'events'), new ApiReferenceCategory()); }); -$app->get('/api-reference/:reference1/:reference2', function ($reference1, $reference2) use ($app) { - - try { - $guide = new ApiReferenceGuide($reference1 . '/' . $reference2); - } catch (DocumentNotExistException $e) { - send404NotFound($app); - return; - } +$app->get('/api-reference/index', function (Request $request, Response $response, $args) { + return renderGuide($this->get("view"), $response, $request->getUri(), new PhpDoc('Index', 'index'), new ApiReferenceCategory()); +}); - renderGuide($app, $guide, new ApiReferenceCategory()); +$app->get('/api-reference/PHP-Piwik-Tracker', function (Request $request, Response $response, $args) { + return renderGuide($this->get("view"), $response, $request->getUri(), new PhpDoc('PiwikTracker', 'PHP-Piwik-Tracker'), new ApiReferenceCategory()); }); -$app->get('/api-reference/:reference', function ($reference) use ($app) { +$app->get('/api-reference/{reference}', function (Request $request, Response $response, $args) { try { - $guide = new ApiReferenceGuide($reference); + $guide = new ApiReferenceGuide($args["reference"]); } catch (DocumentNotExistException $e) { - send404NotFound($app); - return; + throw new \Slim\Exception\HttpNotFoundException($request, $response); } - - renderGuide($app, $guide, new ApiReferenceCategory()); - + return renderGuide($this->get("view"), $response, $request->getUri(), $guide, new ApiReferenceCategory()); }); - -$app->get('/api-reference', function () use ($app) { +$app->get('/api-reference', function (Request $request, Response $response, $args) { $category = new ApiReferenceCategory(); - renderGuide($app, $category->getIntroGuide(), $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $category->getIntroGuide(), $category); }); -$app->get('/support', function () use ($app) { +$app->get('/support', function (Request $request, Response $response, $args) { $category = new SupportCategory(); - renderGuide($app, $category->getIntroGuide(), $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $category->getIntroGuide(), $category); }); -$app->get('/changelog', function () use ($app) { + +$app->get('/changelog', function (Request $request, Response $response, $args) { $fetchContent = false; - $targetFile = '../../docs/changelog.md'; + $targetFile = '../../docs/changelog.md'; if (!file_exists($targetFile)) { $fetchContent = true; @@ -289,26 +164,33 @@ function getUrlIfDocumentIsAvailableInPiwikVersion($app, $piwikVersion) if ($fetchContent) { $markdown = file_get_contents('https://raw.githubusercontent.com/piwik/piwik/3.x-dev/CHANGELOG.md'); + if ($markdown === false) { + throw new \Exception("Could not fetch changelog"); + } file_put_contents($targetFile, $markdown); } $category = new ChangelogCategory(); - renderGuide($app, $category->getIntroGuide(), $category); + return renderGuide($this->get("view"), $response, $request->getUri(), $category->getIntroGuide(), $category); }); -$app->get('/data/documents', function () use ($app) { +$app->get('/data/documents', function (Request $request, Response $response, $args) { $searchIndex = new SearchIndex(); $index = $searchIndex->buildIndex(); - echo json_encode([ + $response->getBody()->write(json_encode([ 'urls' => array_keys($index), 'names' => array_values($index) - ], JSON_PRETTY_PRINT); + ])); + return $response->withHeader('Content-Type', 'application/json') + ->withStatus(200); }); -$app->post('/receive-commit-hook', function () use ($app) { +$app->post('/receive-commit-hook', function (Request $request, Response $response, $args) { system('git pull'); - \helpers\Cache::invalidate(); - echo 'Here is a cookie!'; - exit; -}); + Cache::invalidate(); + Cache::invalidate_Twig_Cache(); + + $response->getBody()->write("Here is a cookie!"); + return $response->withHeader('Content-Type', 'text/plain'); +}); \ No newline at end of file diff --git a/app/templates/base.twig b/app/templates/base.twig index c39717ffd..fdf4a7f28 100644 --- a/app/templates/base.twig +++ b/app/templates/base.twig @@ -50,14 +50,13 @@ Support - {% if availablePiwikVersions|length > 1 %} - {% endif %}