Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aronnebrivio committed Feb 20, 2021
2 parents a00acb6 + 28db1a5 commit da83dbd
Show file tree
Hide file tree
Showing 13 changed files with 3,364 additions and 1,601 deletions.
14 changes: 9 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ APP_TIMEZONE='Europe/Rome'

PHP_HOST_PORT=8081
MYSQL_HOST_PORT=3309
XDEBUG_ENABLE=1
XDEBUG_PORT=9000
XDEBUG_PROFILER_ENABLED=0
UID=1000
REDIS_HOST_PORT=6381

# For accepted values: https://xdebug.org/docs/all_settings#mode
XDEBUG_MODE=develop

DB_CONNECTION=mysql
DB_HOST=blog-db
Expand All @@ -20,5 +20,9 @@ DB_DATABASE=blog_sviluppo
DB_USERNAME=root
DB_PASSWORD=root

CACHE_DRIVER=memcached
REDIS_HOST=blog-redis
REDIS_PORT=6379
REDIS_DATABASE=0

CACHE_DRIVER=redis
QUEUE_DRIVER=sync
52 changes: 22 additions & 30 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
<?php

return PhpCsFixer\Config::create()
->setRules([
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_namespace' => true,
'braces' => true,
'class_definition' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'indentation_type' => true,
'line_ending' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'method_argument_space' => true,
'method_separation' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_extra_consecutive_blank_lines' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'ordered_imports' => ['sortAlgorithm' => 'length'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'single_blank_line_at_eof' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'visibility_required' => true,
'no_unused_imports' => true,
'@PhpCsFixer' => true,
'blank_line_before_statement' => ['statements' => [
'continue',
'declare',
'return',
'throw',
'try',
]],
'cast_spaces' => ['space' => 'none'],
'concat_space' => ['spacing' => 'one'],
'increment_style' => ['style' => 'post'],
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
'no_leading_import_slash' => true,
'no_superfluous_phpdoc_tags' => false,
'ordered_class_elements' => false,
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
'phpdoc_to_comment' => false,
'yoda_style' => false,
'is_null' => ['use_yoda_style' => false],
'no_alias_functions' => true,
'non_printable_character' => ['use_escape_sequences_in_strings' => true],
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Aronne Brivio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Blog backend
[Lumen](https://lumen.laravel.com/) project providing an API to a blog environment, with Users, Posts and Comments.
[![LICENSE](https://img.shields.io/badge/license-MIT-gold.svg)](https://github.com/aronnebrivio/aronnebrivio.github.io/blob/master/LICENSE)

> I'm currently porting this project from Gitlab. I used to automate the deploy with Gitlab CI using [Envoy](https://laravel.com/docs/8.x/envoy). I'll try to use the same approach with Github workflows and, once it will be up and running on a production endpoint, I'll try out new deploy technologies.
Production endpoint: [blog-backend.aronnebrivio.xyz](http://blog-backend.aronnebrivio.xyz)
[Lumen](https://lumen.laravel.com/) project providing an API to a blog environment, with Users, Posts and Comments.

Documentation can be found [here](https://documenter.getpostman.com/view/4711074/SVmr11U3?version=latest).

Expand All @@ -17,12 +19,23 @@ Documentation can be found [here](https://documenter.getpostman.com/view/4711074
- Profit

### Notes
APIs will be available at `http://localhost:PHP_HOST_PORT`, where `PHP_HOST_PORT` is declared in `.env` file.
You can enable or disable XDebug using the `XDEBUG_ENABLE` environment variable.
APIs will be available at `http://localhost:PHP_HOST_PORT`, where `PHP_HOST_PORT` is declared in `.env` file.
You can enable or disable XDebug using the `XDEBUG_MODE` environment variable.

## Test
Tests are under `/tests` folder, run it with `phpunit`.

## ToDo
- Makefile
- Containerized infrastructure for server
- [x] Upgrade to Lumen 8.x
- [x] Upgrade to Composer 3
- [x] Automated PHP-CS-Fixer
- [x] Redis cache
- [x] Clean up local Docker environment
- [ ] Review CI Docker environment
- [ ] Use Github workflow
- [ ] Setup a simple production environment
- [ ] Makefile
- [ ] Containerized infrastructure for server

## License
Copyright (c) 2020 Aronne Brivio. Released under the MIT License. See [LICENSE](https://github.com/aronnebrivio/a-lumen-blog/blob/master/LICENSE) for details.
5 changes: 3 additions & 2 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Throwable;
use UnexpectedValueException;

class Handler extends ExceptionHandler
Expand All @@ -33,7 +34,7 @@ class Handler extends ExceptionHandler
* @param Exception $e
* @throws Exception
*/
public function report(Exception $e)
public function report(Throwable $e)
{
if (app()->environment('production') && app()->bound('sentry') && $this->shouldReport($e)) {
app('sentry')->captureException($e);
Expand All @@ -49,7 +50,7 @@ public function report(Exception $e)
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
public function render($request, Throwable $e)
{
if ($e instanceof ValidationException)
return response($e->validator->messages()->messages(), 422);
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@

$app->register(App\Providers\AuthServiceProvider::class);
$app->register(Sentry\Laravel\ServiceProvider::class);
$app->register(Illuminate\Redis\RedisServiceProvider::class);
$app->register(Illuminate\Database\Eloquent\LegacyFactoryServiceProvider::class);

/*
|--------------------------------------------------------------------------
Expand Down
26 changes: 18 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"keywords": [
"framework",
"laravel",
"lumen"
],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.2.0",
"php": ">=7.4.0",
"doctrine/dbal": "^2.9",
"laravel/lumen-framework": "6.*",
"sentry/sentry-laravel": "^1.5",
"vlucas/phpdotenv": "^3.3"
"illuminate/redis": "^8.28",
"laravel/legacy-factories": "^1.1",
"laravel/lumen-framework": "8.*",
"sentry/sentry-laravel": "2.*",
"vlucas/phpdotenv": "5.*"
},
"require-dev": {
"captainhook/captainhook": "^5.4",
"friendsofphp/php-cs-fixer": "^2.18",
"fzaninotto/faker": "^1.4",
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.0"
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
Expand All @@ -30,7 +38,9 @@
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
]
],
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --allow-risky=yes --config .php_cs.dist --verbose --stop-on-violation --diff -- $(git diff --name-only --diff-filter=d HEAD)",
"post-autoload-dump": "vendor/bin/captainhook install -f -s"
},
"config": {
"preferred-install": "dist",
Expand Down
Loading

0 comments on commit da83dbd

Please sign in to comment.