From 240c12756ba585a28cf610cdac4b37aecc7fa800 Mon Sep 17 00:00:00 2001 From: Maximo Castro Date: Sun, 28 Feb 2021 02:06:08 -0400 Subject: [PATCH 1/2] Router & Swoole Improvements --- src/Bootstrap/Swoole.php | 5 ++--- src/Providers/MiddlewareProvider.php | 8 ++++---- src/Providers/ResponseProvider.php | 4 ++-- src/Providers/RouterProvider.php | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Bootstrap/Swoole.php b/src/Bootstrap/Swoole.php index 42ff5a07..45601465 100644 --- a/src/Bootstrap/Swoole.php +++ b/src/Bootstrap/Swoole.php @@ -24,9 +24,8 @@ class Swoole extends AbstractBootstrap */ public function run() { - return $this->application->handle( - $this->container->getRequest()->getServer('request_uri', null, '/') - ); + $uri = rawurldecode($this->container->getRequest()->getServer('REQUEST_URI') ?? ''); + return $this->application->handle($uri); } /** diff --git a/src/Providers/MiddlewareProvider.php b/src/Providers/MiddlewareProvider.php index 4e180b4e..71201e2b 100644 --- a/src/Providers/MiddlewareProvider.php +++ b/src/Providers/MiddlewareProvider.php @@ -4,15 +4,15 @@ namespace Canvas\Providers; -use Canvas\Middleware\NotFoundMiddleware; use Baka\Router\Providers\MiddlewareProvider as BakaMiddlewareProvider; -use Canvas\Middleware\AuthenticationMiddleware; use Canvas\Middleware\AclMiddleware; +use Canvas\Middleware\ActiveStatusMiddleware; use Canvas\Middleware\AnonymousMiddleware; +use Canvas\Middleware\AuthenticationMiddleware; +use Canvas\Middleware\NotFoundMiddleware; use Canvas\Middleware\SubscriptionMiddleware; -use Canvas\Middleware\ActiveStatusMiddleware; -use Phalcon\Mvc\Micro; use Phalcon\Events\Manager; +use Phalcon\Mvc\Micro; class MiddlewareProvider extends BakaMiddlewareProvider { diff --git a/src/Providers/ResponseProvider.php b/src/Providers/ResponseProvider.php index ad54e251..fbbe78d8 100644 --- a/src/Providers/ResponseProvider.php +++ b/src/Providers/ResponseProvider.php @@ -4,11 +4,11 @@ namespace Canvas\Providers; +use function Baka\isSwooleServer; use Canvas\Http\Response; use Canvas\Http\SwooleResponse; -use Phalcon\Di\ServiceProviderInterface; use Phalcon\Di\DiInterface; -use function Baka\isSwooleServer; +use Phalcon\Di\ServiceProviderInterface; class ResponseProvider implements ServiceProviderInterface { diff --git a/src/Providers/RouterProvider.php b/src/Providers/RouterProvider.php index f5e264bd..a34388e7 100644 --- a/src/Providers/RouterProvider.php +++ b/src/Providers/RouterProvider.php @@ -10,11 +10,11 @@ class RouterProvider extends BakaRouterProvider { /** - * @inheritDoc + * {@inheritdoc} * * @return array */ - protected function getCollections(): array + protected function getCollections() : array { $routerCollections = []; @@ -30,7 +30,7 @@ protected function getCollections(): array * * @return array */ - protected function getRoutes(): array + protected function getRoutes() : array { //when testing change the path of routes $path = !defined('API_TESTS') ? appPath('api/routes') : appPath('routes'); From 2a427f4aabddcc45e904d4541a43e45528431b6d Mon Sep 17 00:00:00 2001 From: Maximo Castro Date: Sun, 28 Feb 2021 18:23:04 -0400 Subject: [PATCH 2/2] Add cache cli --- src/Cli/Tasks/CacheTask.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Cli/Tasks/CacheTask.php diff --git a/src/Cli/Tasks/CacheTask.php b/src/Cli/Tasks/CacheTask.php new file mode 100644 index 00000000..efcea221 --- /dev/null +++ b/src/Cli/Tasks/CacheTask.php @@ -0,0 +1,36 @@ +load(); + + echo 'Copy and past this .env variables to your www.conf on PHP-FPM' . PHP_EOL . PHP_EOL; + + foreach ($_ENV as $key => $value) { + if (!empty($value)) { + echo "env[{$key}] = '{$value}'" . PHP_EOL; + } + } + } +}