diff --git a/composer.json b/composer.json index 3e3fe97..b649edb 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,7 @@ "dasprid/container-interop-doctrine": "^1.1", "doctrine/orm": "^2.6", "gedmo/doctrine-extensions": "^2.4", + "los/basepath": "^2.0", "roave/security-advisories": "dev-master", "symfony/console": "^4.0", "tuupola/cors-middleware": "^0.7.0", diff --git a/composer.lock b/composer.lock index d2f9e66..9e93064 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": "f30cef69b43fa78cf3e1a64684b41ca4", + "content-hash": "dbd785ba02ce109f4eb930114fe2c75a", "packages": [ { "name": "behat/transliterator", @@ -914,6 +914,54 @@ ], "time": "2017-03-24T14:48:51+00:00" }, + { + "name": "los/basepath", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/Lansoweb/basepath.git", + "reference": "877187636f157f7f9d336c7808cfb6aeabc1c686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Lansoweb/basepath/zipball/877187636f157f7f9d336c7808cfb6aeabc1c686", + "reference": "877187636f157f7f9d336c7808cfb6aeabc1c686", + "shasum": "" + }, + "require": { + "php": "^7.1", + "psr/container": "^1.0", + "psr/http-message": "~1.0", + "psr/http-server-middleware": "^1.0" + }, + "require-dev": { + "phpstan/phpstan": "^0.9.2", + "phpunit/phpunit": "^7.0", + "squizlabs/php_codesniffer": "^2.7", + "zendframework/zend-coding-standard": "^1.0", + "zendframework/zend-diactoros": "^1.0", + "zendframework/zend-expressive-helpers": "^5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "LosMiddleware\\BasePath\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Leandro Silva", + "homepage": "http://leandrosilva.info/" + } + ], + "description": "PHP middleware to remove a path prefix from request uri", + "homepage": "https://github.com/lansoweb/basepath", + "time": "2018-03-27T11:46:22+00:00" + }, { "name": "neomerx/cors-psr7", "version": "v1.0.12", diff --git a/config/autoload/los-basepath.global.php b/config/autoload/los-basepath.global.php new file mode 100644 index 0000000..bd679b8 --- /dev/null +++ b/config/autoload/los-basepath.global.php @@ -0,0 +1,9 @@ + [ + 'factories' => [ + LosMiddleware\BasePath\BasePath::class => LosMiddleware\BasePath\BasePathFactory::class, + ], + ], +]; diff --git a/config/autoload/los-basepath.local.php.dist b/config/autoload/los-basepath.local.php.dist new file mode 100644 index 0000000..9a4f461 --- /dev/null +++ b/config/autoload/los-basepath.local.php.dist @@ -0,0 +1,5 @@ + '', +]; diff --git a/config/pipeline.php b/config/pipeline.php index b838955..8ba2e9d 100644 --- a/config/pipeline.php +++ b/config/pipeline.php @@ -23,6 +23,7 @@ return function (Application $app, MiddlewareFactory $factory, ContainerInterfac // The error handler should be the first (most outer) middleware to catch // all Exceptions. $app->pipe(ErrorHandler::class); + $app->pipe(LosMiddleware\BasePath\BasePath::class); $app->pipe(ServerUrlMiddleware::class); // Pipe more middleware here that you want to execute on every request: diff --git a/deploy.php b/deploy.php new file mode 100644 index 0000000..f9aa0e3 --- /dev/null +++ b/deploy.php @@ -0,0 +1,58 @@ +stage('production') + ->user('edvidan') + ->forwardAgent() + ->set('php_service_name', 'php7.1-fpm') + ->set('deploy_path', '/home/edvidan/applications/mtastv-api'); + + +desc('Reload PHP-FPM service'); +task('php-fpm:reload', function () { + // The user must have rights for restart service + // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service + run('sudo service {{php_service_name}} reload'); +}); //->onlyOn('alfheim'); +after('deploy:symlink', 'php-fpm:reload'); + + +desc('Deploy your project'); +task('deploy', [ + 'deploy:prepare', + 'deploy:lock', + 'deploy:release', + 'deploy:update_code', + 'deploy:shared', + 'deploy:writable', + 'deploy:vendors', + 'deploy:clear_paths', + 'deploy:symlink', + 'deploy:unlock', + 'cleanup', +]); + +after('deploy', 'success');