From d3ca5e901a20cbc9946896c17e796441a39dd6cd Mon Sep 17 00:00:00 2001 From: Simon Dann Date: Wed, 4 Apr 2018 09:49:16 +0100 Subject: [PATCH] #3 exception handler (#4) * Use Tuppence ^1.1 * Small update to README * Added boilerplate exception handler * Added example error pages --- README.md | 4 +- composer.json | 2 +- composer.lock | 433 +++++++++++++------------------ resources/views/errors/404.phtml | 1 + resources/views/errors/500.phtml | 1 + src/Exceptions/Handler.php | 65 +++++ src/bootstrap.php | 5 + 7 files changed, 252 insertions(+), 259 deletions(-) create mode 100644 resources/views/errors/404.phtml create mode 100644 resources/views/errors/500.phtml create mode 100644 src/Exceptions/Handler.php diff --git a/README.md b/README.md index 8debe68..f12ed6c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ This boilerplate wraps [Tuppence](https://github.com/photogabble/tuppence) with ## Install -Install this project with composer `composer create-project photogabble/tuppence-boilerplate` +Install this project with composer `composer create-project photogabble/tuppence-boilerplate`. + +For development you can use `php -S 127.0.0.1:3000 -t public` to serve your project locally on [http://127.0.0.1:3000](http://127.0.0.1:3000). ## PSR-7 Support diff --git a/composer.json b/composer.json index 6283e43..d721616 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": ">=5.6.0", "doctrine/dbal": "^2.5", "doctrine/orm": "^2.5", - "photogabble/tuppence": "^1.0", + "photogabble/tuppence": "^1.1", "league/plates": "^3.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index f98aab5..256a77a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "08232604ce02eb83a8b190aeb592b39e", + "content-hash": "24f4a9c4a28dc4ab06fd96330073f804", "packages": [ { "name": "container-interop/container-interop", @@ -39,30 +39,30 @@ }, { "name": "doctrine/annotations", - "version": "v1.4.0", + "version": "v1.6.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", - "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", "shasum": "" }, "require": { "doctrine/lexer": "1.*", - "php": "^5.6 || ^7.0" + "php": "^7.1" }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^6.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -103,37 +103,41 @@ "docblock", "parser" ], - "time": "2017-02-24T16:22:25+00:00" + "time": "2017-12-06T07:11:42+00:00" }, { "name": "doctrine/cache", - "version": "v1.6.2", + "version": "v1.7.1", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b" + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b", - "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b", + "url": "https://api.github.com/repos/doctrine/cache/zipball/b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a", "shasum": "" }, "require": { - "php": "~5.5|~7.0" + "php": "~7.1" }, "conflict": { "doctrine/common": ">2.2,<2.4" }, "require-dev": { - "phpunit/phpunit": "~4.8|~5.0", - "predis/predis": "~1.0", - "satooshi/php-coveralls": "~0.6" + "alcaeus/mongo-php-adapter": "^1.1", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^5.7", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -173,24 +177,24 @@ "cache", "caching" ], - "time": "2017-07-22T12:49:21+00:00" + "time": "2017-08-25T07:02:50+00:00" }, { "name": "doctrine/collections", - "version": "v1.4.0", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/collections.git", - "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba" + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/1a4fb7e902202c33cce8c55989b945612943c2ba", - "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba", + "url": "https://api.github.com/repos/doctrine/collections/zipball/a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" }, "require-dev": { "doctrine/coding-standard": "~0.1@dev", @@ -240,20 +244,20 @@ "collections", "iterator" ], - "time": "2017-01-03T10:49:41+00:00" + "time": "2017-07-22T10:37:32+00:00" }, { "name": "doctrine/common", - "version": "v2.7.3", + "version": "v2.8.1", "source": { "type": "git", "url": "https://github.com/doctrine/common.git", - "reference": "4acb8f89626baafede6ee5475bc5844096eba8a9" + "reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/4acb8f89626baafede6ee5475bc5844096eba8a9", - "reference": "4acb8f89626baafede6ee5475bc5844096eba8a9", + "url": "https://api.github.com/repos/doctrine/common/zipball/f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", + "reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", "shasum": "" }, "require": { @@ -262,15 +266,15 @@ "doctrine/collections": "1.*", "doctrine/inflector": "1.*", "doctrine/lexer": "1.*", - "php": "~5.6|~7.0" + "php": "~7.1" }, "require-dev": { - "phpunit/phpunit": "^5.4.6" + "phpunit/phpunit": "^5.7" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.7.x-dev" + "dev-master": "2.8.x-dev" } }, "autoload": { @@ -313,29 +317,33 @@ "persistence", "spl" ], - "time": "2017-07-22T08:35:12+00:00" + "time": "2017-08-31T08:43:38+00:00" }, { "name": "doctrine/dbal", - "version": "v2.5.13", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "729340d8d1eec8f01bff708e12e449a3415af873" + "reference": "f76bf5ef631cec551a86c2291fc749534febebf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/729340d8d1eec8f01bff708e12e449a3415af873", - "reference": "729340d8d1eec8f01bff708e12e449a3415af873", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/f76bf5ef631cec551a86c2291fc749534febebf1", + "reference": "f76bf5ef631cec551a86c2291fc749534febebf1", "shasum": "" }, "require": { - "doctrine/common": ">=2.4,<2.8-dev", - "php": ">=5.3.2" + "doctrine/common": "^2.7.1", + "ext-pdo": "*", + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "4.*", - "symfony/console": "2.*||^3.0" + "doctrine/coding-standard": "^4.0", + "phpunit/phpunit": "^7.0", + "phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5", + "symfony/console": "^2.0.5||^3.0", + "symfony/phpunit-bridge": "^3.4.5|^4.0.5" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -346,7 +354,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5.x-dev" + "dev-master": "2.7.x-dev" } }, "autoload": { @@ -384,37 +392,37 @@ "persistence", "queryobject" ], - "time": "2017-07-22T20:44:48+00:00" + "time": "2018-04-01T23:33:17+00:00" }, { "name": "doctrine/inflector", - "version": "v1.1.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "90b2128806bfde671b6952ab8bea493942c1fdae" + "reference": "5527a48b7313d15261292c149e55e26eae771b0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", - "reference": "90b2128806bfde671b6952ab8bea493942c1fdae", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", + "reference": "5527a48b7313d15261292c149e55e26eae771b0a", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "^6.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Inflector\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" } }, "notification-url": "https://packagist.org/downloads/", @@ -451,36 +459,36 @@ "singularize", "string" ], - "time": "2015-11-06T14:35:42+00:00" + "time": "2018-01-09T20:05:19+00:00" }, { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -505,7 +513,7 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2017-07-22T11:58:36+00:00" }, { "name": "doctrine/lexer", @@ -563,38 +571,40 @@ }, { "name": "doctrine/orm", - "version": "v2.5.13", + "version": "v2.6.1", "source": { "type": "git", "url": "https://github.com/doctrine/doctrine2.git", - "reference": "93103f44a3e36e7b48165b6e6b736833f33b18ef" + "reference": "87ee409783a4a322b5597ebaae558661404055a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/93103f44a3e36e7b48165b6e6b736833f33b18ef", - "reference": "93103f44a3e36e7b48165b6e6b736833f33b18ef", + "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/87ee409783a4a322b5597ebaae558661404055a7", + "reference": "87ee409783a4a322b5597ebaae558661404055a7", "shasum": "" }, "require": { - "doctrine/cache": "~1.4", - "doctrine/collections": "~1.2", - "doctrine/common": ">=2.5-dev,<2.9-dev", - "doctrine/dbal": ">=2.5-dev,<2.7-dev", - "doctrine/instantiator": "^1.0.1", + "doctrine/annotations": "~1.5", + "doctrine/cache": "~1.6", + "doctrine/collections": "^1.4", + "doctrine/common": "^2.7.1", + "doctrine/dbal": "^2.6", + "doctrine/instantiator": "~1.1", "ext-pdo": "*", - "php": ">=5.4", - "symfony/console": "~2.5|~3.0|~4.0" + "php": "^7.1", + "symfony/console": "~3.0|~4.0" }, "require-dev": { - "phpunit/phpunit": "~4.0", - "symfony/yaml": "~2.3|~3.0|~4.0" + "doctrine/coding-standard": "^1.0", + "phpunit/phpunit": "^6.5", + "squizlabs/php_codesniffer": "^3.2", + "symfony/yaml": "~3.4|~4.0" }, "suggest": { "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" }, "bin": [ - "bin/doctrine", - "bin/doctrine.php" + "bin/doctrine" ], "type": "library", "extra": { @@ -603,8 +613,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\ORM\\": "lib/" + "psr-4": { + "Doctrine\\ORM\\": "lib/Doctrine/ORM" } }, "notification-url": "https://packagist.org/downloads/", @@ -627,6 +637,10 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" } ], "description": "Object-Relational-Mapper for PHP", @@ -635,7 +649,7 @@ "database", "orm" ], - "time": "2017-11-27T23:25:55+00:00" + "time": "2018-02-27T07:30:56+00:00" }, { "name": "league/container", @@ -873,21 +887,24 @@ }, { "name": "nikic/fast-route", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/nikic/FastRoute.git", - "reference": "b5f95749071c82a8e0f58586987627054400cdf6" + "reference": "181d480e08d9476e61381e04a71b34dc0432e812" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/FastRoute/zipball/b5f95749071c82a8e0f58586987627054400cdf6", - "reference": "b5f95749071c82a8e0f58586987627054400cdf6", + "url": "https://api.github.com/repos/nikic/FastRoute/zipball/181d480e08d9476e61381e04a71b34dc0432e812", + "reference": "181d480e08d9476e61381e04a71b34dc0432e812", "shasum": "" }, "require": { "php": ">=5.4.0" }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|~5.7" + }, "type": "library", "autoload": { "psr-4": { @@ -912,20 +929,20 @@ "router", "routing" ], - "time": "2017-01-19T11:35:12+00:00" + "time": "2018-02-13T20:26:39+00:00" }, { "name": "photogabble/tuppence", - "version": "1.0.0", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/photogabble/tuppence.git", - "reference": "5c74a4d6bc1a8cec9d3b583b0340a542b3237c65" + "reference": "395db2db1de947142aea17e389dd65ef7a6f17ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/photogabble/tuppence/zipball/5c74a4d6bc1a8cec9d3b583b0340a542b3237c65", - "reference": "5c74a4d6bc1a8cec9d3b583b0340a542b3237c65", + "url": "https://api.github.com/repos/photogabble/tuppence/zipball/395db2db1de947142aea17e389dd65ef7a6f17ad", + "reference": "395db2db1de947142aea17e389dd65ef7a6f17ad", "shasum": "" }, "require": { @@ -955,7 +972,7 @@ } ], "description": "Extremely small framework.", - "time": "2017-11-30T11:57:10+00:00" + "time": "2017-12-04T14:49:38+00:00" }, { "name": "psr/container", @@ -1056,70 +1073,22 @@ ], "time": "2016-08-06T14:39:51+00:00" }, - { - "name": "psr/log", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2016-10-10T12:19:37+00:00" - }, { "name": "symfony/console", - "version": "v3.4.0", + "version": "v4.0.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0" + "reference": "aad9a6fe47319f22748fd764f52d3a7ca6fa6b64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0", - "reference": "9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0", + "url": "https://api.github.com/repos/symfony/console/zipball/aad9a6fe47319f22748fd764f52d3a7ca6fa6b64", + "reference": "aad9a6fe47319f22748fd764f52d3a7ca6fa6b64", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0|~4.0", + "php": "^7.1.3", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { @@ -1128,11 +1097,11 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3|~4.0", + "symfony/config": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.3|~4.0" + "symfony/process": "~3.4|~4.0" }, "suggest": { "psr/log": "For using the console logger", @@ -1143,7 +1112,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1170,76 +1139,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-11-29T13:28:14+00:00" - }, - { - "name": "symfony/debug", - "version": "v3.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "fb2001e5d85f95d8b6ab94ae3be5d2672df128fd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/fb2001e5d85f95d8b6ab94ae3be5d2672df128fd", - "reference": "fb2001e5d85f95d8b6ab94ae3be5d2672df128fd", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2017-11-21T09:01:46+00:00" + "time": "2018-04-03T05:24:00+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.6.0", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", "shasum": "" }, "require": { @@ -1251,7 +1164,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.7-dev" } }, "autoload": { @@ -1285,20 +1198,20 @@ "portable", "shim" ], - "time": "2017-10-11T12:05:26+00:00" + "time": "2018-01-30T19:27:44+00:00" }, { "name": "zendframework/zend-diactoros", - "version": "1.6.1", + "version": "1.7.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "c8664b92a6d5bc229e48b0923486c097e45a7877" + "reference": "bf26aff803a11c5cc8eb7c4878a702c403ec67f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/c8664b92a6d5bc229e48b0923486c097e45a7877", - "reference": "c8664b92a6d5bc229e48b0923486c097e45a7877", + "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/bf26aff803a11c5cc8eb7c4878a702c403ec67f1", + "reference": "bf26aff803a11c5cc8eb7c4878a702c403ec67f1", "shasum": "" }, "require": { @@ -1317,8 +1230,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev", - "dev-develop": "1.7-dev" + "dev-master": "1.7.x-dev", + "dev-develop": "1.8.x-dev" } }, "autoload": { @@ -1337,7 +1250,7 @@ "psr", "psr-7" ], - "time": "2017-10-12T15:24:51+00:00" + "time": "2018-02-26T15:44:50+00:00" } ], "packages-dev": [ @@ -1442,29 +1355,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.3.2", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2", - "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0", + "php": "^7.0", "phpdocumentor/reflection-common": "^1.0.0", "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -1483,7 +1402,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-10T14:09:06+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1534,16 +1453,16 @@ }, { "name": "phpspec/prophecy", - "version": "1.7.3", + "version": "1.7.5", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf" + "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", - "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", "shasum": "" }, "require": { @@ -1555,7 +1474,7 @@ }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" }, "type": "library", "extra": { @@ -1593,7 +1512,7 @@ "spy", "stub" ], - "time": "2017-11-24T13:59:53+00:00" + "time": "2018-02-19T10:16:54+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1797,29 +1716,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.2.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1842,20 +1761,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.25", + "version": "5.7.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a" + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4b1c822a68ae6577df38a59eb49b046712ec0f6a", - "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", "shasum": "" }, "require": { @@ -1879,7 +1798,7 @@ "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", + "sebastian/version": "^1.0.6|^2.0.1", "symfony/yaml": "~2.1|~3.0|~4.0" }, "conflict": { @@ -1924,7 +1843,7 @@ "testing", "xunit" ], - "time": "2017-11-14T14:50:51+00:00" + "time": "2018-02-01T05:50:59+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -2500,20 +2419,20 @@ }, { "name": "symfony/yaml", - "version": "v3.4.0", + "version": "v4.0.7", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "b3d0c9c11be3831b84825967dc6b52b5a7b84e04" + "reference": "8b34ebb5989df61cbd77eff29a02c4db9ac1069c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/b3d0c9c11be3831b84825967dc6b52b5a7b84e04", - "reference": "b3d0c9c11be3831b84825967dc6b52b5a7b84e04", + "url": "https://api.github.com/repos/symfony/yaml/zipball/8b34ebb5989df61cbd77eff29a02c4db9ac1069c", + "reference": "8b34ebb5989df61cbd77eff29a02c4db9ac1069c", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3" }, "conflict": { "symfony/console": "<3.4" @@ -2527,7 +2446,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2554,20 +2473,20 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-11-29T13:28:14+00:00" + "time": "2018-04-03T05:24:00+00:00" }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { @@ -2604,7 +2523,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], diff --git a/resources/views/errors/404.phtml b/resources/views/errors/404.phtml new file mode 100644 index 0000000..466a3d1 --- /dev/null +++ b/resources/views/errors/404.phtml @@ -0,0 +1 @@ +File not found. \ No newline at end of file diff --git a/resources/views/errors/500.phtml b/resources/views/errors/500.phtml new file mode 100644 index 0000000..bd238c6 --- /dev/null +++ b/resources/views/errors/500.phtml @@ -0,0 +1 @@ +Server Error. \ No newline at end of file diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php new file mode 100644 index 0000000..eb1bd31 --- /dev/null +++ b/src/Exceptions/Handler.php @@ -0,0 +1,65 @@ +app = $app; + } + + /** + * @param Exception|RouteNotFoundException|ContainerNotFoundException $e + * @param RequestInterface $request + * @return \Psr\Http\Message\ResponseInterface + * @throws Exception + */ + public function __invoke(Exception $e, RequestInterface $request) + { + if (in_array(get_class($e), $this->ignore)) { + throw $e; + } + + $status = (method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500); + $viewFilePath = APP_ROOT . '/resources/views/errors/' . $status . '.phtml'; + + if (file_exists($viewFilePath)){ + /** @var Engine $plates */ + $plates = $this->app->getContainer()->get(Engine::class); + return new HtmlResponse($plates->render('errors/' .$status, ['e' => $e]), $status); + } + + return new JsonResponse([ + 'message' => $e->getMessage(), + 'trace' => explode(PHP_EOL, $e->getTraceAsString()) + ], $status); + } + +} \ No newline at end of file diff --git a/src/bootstrap.php b/src/bootstrap.php index 55e1ed7..18dda3c 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -5,6 +5,11 @@ include APP_ROOT . '/vendor/autoload.php'; $app = new \Photogabble\Tuppence\App(); +try { + $app->setExceptionHandler(new \App\Exceptions\Handler($app)); +} catch (\Photogabble\Tuppence\ErrorHandlers\InvalidHandlerException $e) { + echo $e->getMessage(); die(); +} // // Config