Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.3] Router & Swoole Improvements #626

Draft
wants to merge 2 commits into
base: 0.3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Bootstrap/Swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
36 changes: 36 additions & 0 deletions src/Cli/Tasks/CacheTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Canvas\Cli\Tasks;

use function Baka\appPath;
use Dotenv\Dotenv;
use Phalcon\Cli\Task as PhTask;

class CacheTask extends PhTask
{
/**
* Clears the data cache from the application.
*/
public function mainAction() : void
{
}

/**
* Set up the .env environment in production.
*
* @return void
*/
public function dotenvAction()
{
$dotenv = Dotenv::createImmutable(appPath());
$dotenv->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;
}
}
}
}
8 changes: 4 additions & 4 deletions src/Providers/MiddlewareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/Providers/ResponseProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions src/Providers/RouterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
class RouterProvider extends BakaRouterProvider
{
/**
* @inheritDoc
* {@inheritdoc}
*
* @return array
*/
protected function getCollections(): array
protected function getCollections() : array
{
$routerCollections = [];

Expand All @@ -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');
Expand Down