diff --git a/composer.json b/composer.json index a304af2..54e25d9 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,9 @@ "selami/commands": "^0.2", "zendframework/zend-servicemanager": "^3.3", "selami/zend-servicemanager-factories": "^0.6", - "symfony/http-foundation": "^4.1" + "symfony/http-foundation": "^4.1", + "psr/http-server-middleware": "^1.0", + "zendframework/zend-stratigility": "^3.0" }, "require-dev": { "roave/security-advisories": "dev-master", @@ -31,7 +33,11 @@ "minimum-stability": "stable", "autoload": { "psr-4": { - "SelamiApp\\Controller\\": "src/apps/www/controllers" + "Selami\\Auth\\Controller\\": "src/apps/www/middlewares/Auth/controllers", + "Selami\\App\\Controller\\": "src/apps/www/middlewares/App/controllers", + "Selami\\Middleware\\": "src/apps/www/middlewares", + "Selami\\AppFactories\\": "src/factories", + "Selami\\Helper\\": "src/helpers" } }, "scripts": { diff --git a/composer.lock b/composer.lock index 66c9e8e..8c49ddf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "227874d3443b7499c3ccf9405a54f8bc", + "content-hash": "6079e2295387ebe9def0bfa3b6b72eef", "packages": [ { "name": "container-interop/container-interop", @@ -37,6 +37,56 @@ "homepage": "https://github.com/container-interop/container-interop", "time": "2017-02-14T19:40:03+00:00" }, + { + "name": "fig/http-message-util", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message-util.git", + "reference": "20b2c280cb6914b7b83089720df44e490f4b42f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message-util/zipball/20b2c280cb6914b7b83089720df44e490f4b42f0", + "reference": "20b2c280cb6914b7b83089720df44e490f4b42f0", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "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": "2017-02-09T16:10:21+00:00" + }, { "name": "nikic/fast-route", "version": "v1.3.0", @@ -182,6 +232,112 @@ ], "time": "2016-08-06T14:39:51+00:00" }, + { + "name": "psr/http-server-handler", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "439d92054dc06097f2406ec074a2627839955a02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/439d92054dc06097f2406ec074a2627839955a02", + "reference": "439d92054dc06097f2406ec074a2627839955a02", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side request handler", + "keywords": [ + "handler", + "http", + "http-interop", + "psr", + "psr-15", + "psr-7", + "request", + "response", + "server" + ], + "time": "2018-01-22T17:04:15+00:00" + }, + { + "name": "psr/http-server-middleware", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "ea17eb1fb2c8df6db919cc578451a8013c6a0ae5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/ea17eb1fb2c8df6db919cc578451a8013c6a0ae5", + "reference": "ea17eb1fb2c8df6db919cc578451a8013c6a0ae5", + "shasum": "" + }, + "require": { + "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": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side middleware", + "keywords": [ + "http", + "http-interop", + "middleware", + "psr", + "psr-15", + "psr-7", + "request", + "response" + ], + "time": "2018-01-22T17:08:31+00:00" + }, { "name": "selami/commands", "version": "0.2.1", @@ -266,16 +422,16 @@ }, { "name": "selami/foundation", - "version": "0.11", + "version": "0.11.1", "source": { "type": "git", "url": "https://github.com/selamiphp/foundation.git", - "reference": "444de38b2424108a3e3550e309fa9d5c77529ec8" + "reference": "52ce1a74c28d3d909ccb577a681d47cef0d0a55b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/selamiphp/foundation/zipball/444de38b2424108a3e3550e309fa9d5c77529ec8", - "reference": "444de38b2424108a3e3550e309fa9d5c77529ec8", + "url": "https://api.github.com/repos/selamiphp/foundation/zipball/52ce1a74c28d3d909ccb577a681d47cef0d0a55b", + "reference": "52ce1a74c28d3d909ccb577a681d47cef0d0a55b", "shasum": "" }, "require": { @@ -321,7 +477,7 @@ "micro framework", "twig" ], - "time": "2018-07-11T09:56:04+00:00" + "time": "2018-07-21T16:23:11+00:00" }, { "name": "selami/router", @@ -476,21 +632,21 @@ }, { "name": "selami/zend-servicemanager-factories", - "version": "0.6.4", + "version": "0.6.5", "source": { "type": "git", "url": "https://github.com/selamiphp/zend-servicemanager-factories.git", - "reference": "4e14a0ccee1c0c53f1df10b8f8a6f9cd6b83c3d6" + "reference": "05cde89e0fd6ae4db49e0171dd67a232e150c4f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/selamiphp/zend-servicemanager-factories/zipball/4e14a0ccee1c0c53f1df10b8f8a6f9cd6b83c3d6", - "reference": "4e14a0ccee1c0c53f1df10b8f8a6f9cd6b83c3d6", + "url": "https://api.github.com/repos/selamiphp/zend-servicemanager-factories/zipball/05cde89e0fd6ae4db49e0171dd67a232e150c4f7", + "reference": "05cde89e0fd6ae4db49e0171dd67a232e150c4f7", "shasum": "" }, "require": { "php": "^7.1", - "zendframework/zend-servicemanager": "~3.3" + "zendframework/zend-servicemanager": "^3.3" }, "type": "library", "autoload": { @@ -512,7 +668,7 @@ } ], "description": "Predefined factories to used with Zend Service Manager and Selami", - "time": "2017-10-17T08:34:03+00:00" + "time": "2018-07-22T11:34:27+00:00" }, { "name": "symfony/console", @@ -636,6 +792,61 @@ "homepage": "https://symfony.com", "time": "2018-06-19T21:38:16+00:00" }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.8.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-04-30T19:57:29+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.8.0", @@ -802,20 +1013,21 @@ }, { "name": "twig/twig", - "version": "v2.4.8", + "version": "v2.5.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "7b604c89da162034bdf4bb66310f358d313dd16d" + "reference": "6a5f676b77a90823c2d4eaf76137b771adf31323" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/7b604c89da162034bdf4bb66310f358d313dd16d", - "reference": "7b604c89da162034bdf4bb66310f358d313dd16d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/6a5f676b77a90823c2d4eaf76137b771adf31323", + "reference": "6a5f676b77a90823c2d4eaf76137b771adf31323", "shasum": "" }, "require": { "php": "^7.0", + "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -826,7 +1038,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -855,29 +1067,29 @@ }, { "name": "Twig Team", - "homepage": "http://twig.sensiolabs.org/contributors", + "homepage": "https://twig.symfony.com/contributors", "role": "Contributors" } ], "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", + "homepage": "https://twig.symfony.com", "keywords": [ "templating" ], - "time": "2018-04-02T09:24:19+00:00" + "time": "2018-07-13T07:18:09+00:00" }, { "name": "zendframework/zend-diactoros", - "version": "1.8.1", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "63d920d1c9ebc009d860c3666593a66298727dd6" + "reference": "273c18bf6aaab20be9667a3aa4e7702e1e4e7ced" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/63d920d1c9ebc009d860c3666593a66298727dd6", - "reference": "63d920d1c9ebc009d860c3666593a66298727dd6", + "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/273c18bf6aaab20be9667a3aa4e7702e1e4e7ced", + "reference": "273c18bf6aaab20be9667a3aa4e7702e1e4e7ced", "shasum": "" }, "require": { @@ -927,7 +1139,52 @@ "psr", "psr-7" ], - "time": "2018-07-09T21:17:27+00:00" + "time": "2018-07-19T18:38:31+00:00" + }, + { + "name": "zendframework/zend-escaper", + "version": "2.6.0", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-escaper.git", + "reference": "31d8aafae982f9568287cb4dce987e6aff8fd074" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/31d8aafae982f9568287cb4dce987e6aff8fd074", + "reference": "31d8aafae982f9568287cb4dce987e6aff8fd074", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2", + "zendframework/zend-coding-standard": "~1.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6.x-dev", + "dev-develop": "2.7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Escaper\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs", + "keywords": [ + "ZendFramework", + "escaper", + "zf" + ], + "time": "2018-04-25T15:48:53+00:00" }, { "name": "zendframework/zend-servicemanager", @@ -1042,6 +1299,72 @@ "zf" ], "time": "2018-04-30T13:50:40+00:00" + }, + { + "name": "zendframework/zend-stratigility", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-stratigility.git", + "reference": "1efae7142c64a795034fd0dbf8013aa8f531edf3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-stratigility/zipball/1efae7142c64a795034fd0dbf8013aa8f531edf3", + "reference": "1efae7142c64a795034fd0dbf8013aa8f531edf3", + "shasum": "" + }, + "require": { + "fig/http-message-util": "^1.1", + "php": "^7.1", + "psr/http-message": "^1.0", + "psr/http-server-middleware": "^1.0", + "zendframework/zend-escaper": "^2.3" + }, + "conflict": { + "zendframework/zend-diactoros": "<1.7.1" + }, + "require-dev": { + "malukenho/docheader": "^0.1.6", + "phpunit/phpunit": "^7.0.1", + "zendframework/zend-coding-standard": "~1.0.0", + "zendframework/zend-diactoros": "^1.7.1" + }, + "suggest": { + "psr/http-message-implementation": "Please install a psr/http-message-implementation to consume Stratigility; e.g., zendframework/zend-diactoros" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev", + "dev-develop": "3.1.x-dev" + } + }, + "autoload": { + "files": [ + "src/functions/double-pass-middleware.php", + "src/functions/host.php", + "src/functions/middleware.php", + "src/functions/path.php" + ], + "psr-4": { + "Zend\\Stratigility\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "PSR-7 middleware foundation for building and dispatching middleware pipelines", + "keywords": [ + "ZendFramework", + "http", + "middleware", + "psr-15", + "psr-7", + "zf" + ], + "time": "2018-04-04T17:47:35+00:00" } ], "packages-dev": [ @@ -1106,16 +1429,16 @@ }, { "name": "codeception/codeception", - "version": "2.4.3", + "version": "2.4.4", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "13b2db0d54068afaabf3ca8ac8b6591d69018f46" + "reference": "2060fc1fe8ac2823ff3b8ece04616fc12aca968a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/13b2db0d54068afaabf3ca8ac8b6591d69018f46", - "reference": "13b2db0d54068afaabf3ca8ac8b6591d69018f46", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/2060fc1fe8ac2823ff3b8ece04616fc12aca968a", + "reference": "2060fc1fe8ac2823ff3b8ece04616fc12aca968a", "shasum": "" }, "require": { @@ -1193,7 +1516,7 @@ "functional testing", "unit testing" ], - "time": "2018-06-26T14:09:28+00:00" + "time": "2018-07-16T08:14:50+00:00" }, { "name": "codeception/phpunit-wrapper", @@ -2322,12 +2645,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "731d60f7fc78a8816dae7049df255cd55e30c313" + "reference": "053766d789f6393e5bc0896635d35abf8d2d362e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/731d60f7fc78a8816dae7049df255cd55e30c313", - "reference": "731d60f7fc78a8816dae7049df255cd55e30c313", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/053766d789f6393e5bc0896635d35abf8d2d362e", + "reference": "053766d789f6393e5bc0896635d35abf8d2d362e", "shasum": "" }, "conflict": { @@ -2376,7 +2699,7 @@ "kreait/firebase-php": ">=3.2,<3.8.1", "laravel/framework": ">=4,<4.0.99|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.40|>=5.6,<5.6.15", "laravel/socialite": ">=1,<1.0.99|>=2,<2.0.10", - "magento/magento1ce": ">=1.5.0.1,<1.9.3.2", + "magento/magento1ce": "<1.9.3.9", "magento/magento1ee": ">=1.9,<1.14.3.2", "magento/product-community-edition": ">=2,<2.2.5", "monolog/monolog": ">=1.8,<1.12", @@ -2434,7 +2757,8 @@ "thelia/thelia": ">=2.1,<2.1.2|>=2.1.0-beta1,<2.1.3", "titon/framework": ">=0,<9.9.99", "twig/twig": "<1.20", - "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.22|>=8,<8.7.5", + "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.30|>=8,<8.7.17|>=9,<9.3.2", + "typo3/cms-core": ">=8,<8.7.17|>=9,<9.3.2", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5", "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", "willdurand/js-translation-bundle": "<2.1.1", @@ -2483,7 +2807,7 @@ } ], "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", - "time": "2018-07-09T14:09:25+00:00" + "time": "2018-07-18T13:51:34+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2532,16 +2856,16 @@ }, { "name": "sebastian/comparator", - "version": "3.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "591a30922f54656695e59b1f39501aec513403da" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/591a30922f54656695e59b1f39501aec513403da", - "reference": "591a30922f54656695e59b1f39501aec513403da", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { @@ -2592,7 +2916,7 @@ "compare", "equality" ], - "time": "2018-06-14T15:05:28+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", @@ -3327,61 +3651,6 @@ "homepage": "https://symfony.com", "time": "2018-06-19T21:38:16+00:00" }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.8.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae", - "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2018-04-30T19:57:29+00:00" - }, { "name": "symfony/yaml", "version": "v4.1.1", diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index 9d5a3ff..a31124d 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -5,13 +5,15 @@ use Selami\Router; use Selami\View\ViewInterface as SelamiView; use Twig_Environment as TwigEnvironment; -use Selami\Foundation\App as SelamiApplication; use Selami\Factories; +use Selami\AppFactories; + return [ 'dependencies' => [ 'factories' => [ ServerRequestInterface::class => Factories\ServerRequestFactory::class, - SelamiApplication::class => Factories\SelamiApplicationFactory::class, + SelamiApplication::class => AppFactories\SelamiAppFactory::class, + SelamiAuth::class => AppFactories\SelamiAuthFactory::class, Router::class => Factories\RouterFactory::class, TwigEnvironment::class => Factories\TwigFactory::class, SelamiView::class => Factories\SelamiViewTwigFactory::class diff --git a/config/container.php b/config/container.php index 1a2e243..2471c5b 100644 --- a/config/container.php +++ b/config/container.php @@ -11,9 +11,6 @@ $config['app']['base_url'] = BaseUrlExtractor::getBaseUrl($_SERVER); } $container = new ServiceManager($config['dependencies']); -if (isset($routes)) { - $container->setService('routes', $routes); -} $container->setService('config', $config); $container->setService('globals', $globals); $container->setService('commands', $config['commands']); diff --git a/src/apps/bootstrap.php b/src/apps/bootstrap.php index f81e84c..2768120 100644 --- a/src/apps/bootstrap.php +++ b/src/apps/bootstrap.php @@ -1,13 +1,6 @@ get(App::class); -$myApp->sendResponse(); + diff --git a/src/apps/www/bootstrap.php b/src/apps/www/bootstrap.php index 0855681..78009b1 100644 --- a/src/apps/www/bootstrap.php +++ b/src/apps/www/bootstrap.php @@ -1,9 +1,42 @@ pipe(doublePassMiddleware(function (ServerRequestInterface $request, $response, $next) { + $request = $request->withAttribute('selamiAuth', 'pass'); + $response = $next($request, $response->withHeader('X-Auth', 'Pass')); + return $response; +}, new Response())); + +// Auth Middleware +$app->pipe(path('/auth', new AuthMiddleware($container))); + +// APP +$app->pipe(new ApplicationMiddleware($container)); + + + + + +$server->listen(); + diff --git a/src/apps/www/controllers/Application.php b/src/apps/www/controllers/Application.php deleted file mode 100644 index 0ef38ea..0000000 --- a/src/apps/www/controllers/Application.php +++ /dev/null @@ -1,26 +0,0 @@ -container = $container; + } + + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface + { + $appRoutes = require __DIR__ . '/routes.php'; + $this->container->setService('routes', $appRoutes); + $this->container->setService(ServerRequestInterface::class, $request); + $myApp = $this->container->get('SelamiApplication'); + return $myApp($request, new Response()); + } + + +} \ No newline at end of file diff --git a/src/apps/www/middlewares/App/controllers/Application.php b/src/apps/www/middlewares/App/controllers/Application.php new file mode 100644 index 0000000..694984d --- /dev/null +++ b/src/apps/www/middlewares/App/controllers/Application.php @@ -0,0 +1,16 @@ + 200, + 'data' => [ + 'selamiAuth' => $this->request->getAttribute('selamiAuth') + ] + ]; + } +} diff --git a/src/apps/www/controllers/Contents/NotFound.php b/src/apps/www/middlewares/App/controllers/Contents/NotFound.php similarity index 100% rename from src/apps/www/controllers/Contents/NotFound.php rename to src/apps/www/middlewares/App/controllers/Contents/NotFound.php diff --git a/src/apps/www/controllers/Contents/Post.php b/src/apps/www/middlewares/App/controllers/Contents/Post.php similarity index 100% rename from src/apps/www/controllers/Contents/Post.php rename to src/apps/www/middlewares/App/controllers/Contents/Post.php diff --git a/src/apps/www/routes.php b/src/apps/www/middlewares/App/routes.php similarity index 95% rename from src/apps/www/routes.php rename to src/apps/www/middlewares/App/routes.php index 510b961..ff7cbf8 100644 --- a/src/apps/www/routes.php +++ b/src/apps/www/middlewares/App/routes.php @@ -1,7 +1,7 @@ container = $container; + } + + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface + { + $appRoutes = require __DIR__ . '/routes.php'; + $this->container->setService('routes', $appRoutes); + $this->container->setService(ServerRequestInterface::class, $request); + $myApp = $this->container->get('SelamiAuth'); + return $myApp($request, new Response()); + } + + +} \ No newline at end of file diff --git a/src/apps/www/middlewares/Auth/controllers/Application.php b/src/apps/www/middlewares/Auth/controllers/Application.php new file mode 100644 index 0000000..5de6f27 --- /dev/null +++ b/src/apps/www/middlewares/Auth/controllers/Application.php @@ -0,0 +1,16 @@ +session = $session; + $this->request = $request; + $this->args = $args; + } +} diff --git a/src/apps/www/middlewares/Auth/controllers/Auth/Main.php b/src/apps/www/middlewares/Auth/controllers/Auth/Main.php new file mode 100644 index 0000000..27a6dda --- /dev/null +++ b/src/apps/www/middlewares/Auth/controllers/Auth/Main.php @@ -0,0 +1,20 @@ + 200, + 'meta' => [ + 'layout' => 'auth' + ], + 'data' => ['t' => self::class] + ]; + } +} diff --git a/src/apps/www/controllers/Contents/Main.php b/src/apps/www/middlewares/Auth/controllers/Auth/NotFound.php similarity index 56% rename from src/apps/www/controllers/Contents/Main.php rename to src/apps/www/middlewares/Auth/controllers/Auth/NotFound.php index d56fc57..69c8727 100644 --- a/src/apps/www/controllers/Contents/Main.php +++ b/src/apps/www/middlewares/Auth/controllers/Auth/NotFound.php @@ -5,10 +5,10 @@ use Selami\Interfaces\Application; -class Main extends ContentsController implements Application +class NotFound extends ContentsController implements Application { public function __invoke() : array { - return ['status' => 200, 'data' => ['t' => self::class]]; + return ['status' => 404, 'data' => ['t' => 'Main']]; } } diff --git a/src/apps/www/middlewares/Auth/routes.php b/src/apps/www/middlewares/Auth/routes.php new file mode 100644 index 0000000..5ca2e29 --- /dev/null +++ b/src/apps/www/middlewares/Auth/routes.php @@ -0,0 +1,10 @@ + + +
+ +