Skip to content

Commit

Permalink
Merge pull request #92 from maurobonfietti/1.2.0
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
maurobonfietti authored Jun 11, 2020
2 parents e695613 + e46c2b1 commit 3a61463
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ build:
DB_DATABASE: 'rest_api_slim_php'
DB_USERNAME: 'root'
DB_PASSWORD: ''
SECRET_KEY: 'YourSuperSecret-KeY'
REDIS_ENABLED: true
REDIS_URL: 'localhost'
php:
version: 7.4
Expand Down
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PWD := $(dir $(MAKEPATH))
CONTAINERS := $(shell docker ps -a -q -f "name=rest-api-slim-php*")

db:
docker-compose exec mysql mysql -e 'DROP DATABASE IF EXISTS rest_api_slim_php ; CREATE DATABASE rest_api_slim_php;'
docker-compose exec mysql sh -c "mysql rest_api_slim_php < docker-entrypoint-initdb.d/database.sql"

coverage:
docker-compose exec php-fpm sh -c "./vendor/bin/phpunit --coverage-text --coverage-html coverage"

vendor:
docker-compose exec php-fpm sh -c "composer install"

up:
docker-compose up -d --build

Expand All @@ -31,3 +21,13 @@ phplog:

nginxlog:
docker logs rest-api-slim-php-nginx-container

db:
docker-compose exec mysql mysql -e 'DROP DATABASE IF EXISTS rest_api_slim_php ; CREATE DATABASE rest_api_slim_php;'
docker-compose exec mysql sh -c "mysql rest_api_slim_php < docker-entrypoint-initdb.d/database.sql"

coverage:
docker-compose exec php-fpm sh -c "./vendor/bin/phpunit --coverage-text --coverage-html coverage"

vendor:
docker-compose exec php-fpm sh -c "composer install"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ This simple RESTful API, allows CRUD operations to manage resources like: Users,

[![Software License][ico-license]](LICENSE.md)
[![Build Status](https://travis-ci.org/maurobonfietti/rest-api-slim-php.svg?branch=master)](https://travis-ci.org/maurobonfietti/rest-api-slim-php)
[![Test Coverage](https://codeclimate.com/github/maurobonfietti/api-rest-slimphp/badges/coverage.svg)](https://codeclimate.com/github/maurobonfietti/api-rest-slimphp/coverage)
[![Code Quality](https://scrutinizer-ci.com/g/maurobonfietti/api-rest-slimphp/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/maurobonfietti/api-rest-slimphp/?branch=master)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=maurobonfietti_rest-api-slim-php&metric=alert_status)](https://sonarcloud.io/dashboard?id=maurobonfietti_rest-api-slim-php)
[![Code Quality](https://scrutinizer-ci.com/g/maurobonfietti/api-rest-slimphp/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/maurobonfietti/api-rest-slimphp/?branch=master)
[![Test Coverage](https://codeclimate.com/github/maurobonfietti/api-rest-slimphp/badges/coverage.svg)](https://codeclimate.com/github/maurobonfietti/api-rest-slimphp/coverage)
[![Packagist Version](https://img.shields.io/packagist/v/maurobonfietti/rest-api-slim-php)](https://packagist.org/packages/maurobonfietti/rest-api-slim-php)

You can also read this [README IN SPANISH](README_SPANISH.md).

Main technologies used: `PHP 7, Slim 3, MySQL, Redis, dotenv, PHPUnit and JSON Web Tokens.`

Also, I use other aditional tools like: `Docker & Docker Compose, Travis CI, Swagger, Code Climate, Scrutinizer, Sonar Cloud, PHPStan, PHP Insights, Heroku, CORS, Composer and Git.`
Also, I use other aditional tools like: `Docker & Docker Compose, Travis CI, Swagger, Code Climate, Scrutinizer, Sonar Cloud, PHPStan, PHP Insights, Heroku and CORS.`

More info about this project in my post: [How to create a REST API using Slim PHP](https://maurobonfietti.github.io/2019-06-03-rest-api-slim-php/).

Expand Down
6 changes: 3 additions & 3 deletions README_SPANISH.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Esta simple API RESTful, permite operaciones CRUD para administrar recursos como

[![Software License][ico-license]](LICENSE.md)
[![Build Status](https://travis-ci.org/maurobonfietti/rest-api-slim-php.svg?branch=master)](https://travis-ci.org/maurobonfietti/rest-api-slim-php)
[![Test Coverage](https://codeclimate.com/github/maurobonfietti/api-rest-slimphp/badges/coverage.svg)](https://codeclimate.com/github/maurobonfietti/api-rest-slimphp/coverage)
[![Code Quality](https://scrutinizer-ci.com/g/maurobonfietti/api-rest-slimphp/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/maurobonfietti/api-rest-slimphp/?branch=master)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=maurobonfietti_rest-api-slim-php&metric=alert_status)](https://sonarcloud.io/dashboard?id=maurobonfietti_rest-api-slim-php)
[![Code Quality](https://scrutinizer-ci.com/g/maurobonfietti/api-rest-slimphp/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/maurobonfietti/api-rest-slimphp/?branch=master)
[![Test Coverage](https://codeclimate.com/github/maurobonfietti/api-rest-slimphp/badges/coverage.svg)](https://codeclimate.com/github/maurobonfietti/api-rest-slimphp/coverage)
[![Packagist Version](https://img.shields.io/packagist/v/maurobonfietti/rest-api-slim-php)](https://packagist.org/packages/maurobonfietti/rest-api-slim-php)

También puedes leerlo en inglés [README IN ENGLISH](README.md).

Principales tecnologías utilizadas: `PHP 7, Slim 3, MySQL, Redis, dotenv, PHPUnit and JSON Web Tokens.`

Además, utilizo otras herramientas adicionales como: `Docker & Docker Compose, Travis CI, Swagger, Code Climate, Scrutinizer, Sonar Cloud, PHPStan, PHP Insights, Heroku, CORS, Composer and Git.`
Además, utilizo otras herramientas adicionales como: `Docker & Docker Compose, Travis CI, Swagger, Code Climate, Scrutinizer, Sonar Cloud, PHPStan, PHP Insights, Heroku and CORS.`

Más información sobre este proyecto en mi publicación: [Cómo crear una API REST con Slim PHP](https://maurobonfietti.github.io/2019-06-03-rest-api-slim-php/).

Expand Down
7 changes: 2 additions & 5 deletions src/App/Dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@

$container['db'] = static function (ContainerInterface $c): PDO {
$db = $c->get('settings')['db'];
$pdo = new PDO(
sprintf('mysql:host=%s;dbname=%s', $db['hostname'], $db['database']),
$db['username'],
$db['password']
);
$dsn = sprintf('mysql:host=%s;dbname=%s', $db['hostname'], $db['database']);
$pdo = new PDO($dsn, $db['username'], $db['password']);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
Expand Down
12 changes: 9 additions & 3 deletions src/App/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@

$container = $app->getContainer();

$container['user_service'] = static fn (ContainerInterface $container): UserService => new UserService($container->get('user_repository'), $container->get('redis_service'));
$container['user_service'] = static function (ContainerInterface $container): UserService {
return new UserService($container->get('user_repository'), $container->get('redis_service'));
};

$container['task_service'] = static fn (ContainerInterface $container): TaskService => new TaskService($container->get('task_repository'), $container->get('redis_service'));
$container['task_service'] = static function (ContainerInterface $container): TaskService {
return new TaskService($container->get('task_repository'), $container->get('redis_service'));
};

$container['note_service'] = static fn (ContainerInterface $container): NoteService => new NoteService($container->get('note_repository'), $container->get('redis_service'));
$container['note_service'] = static function (ContainerInterface $container): NoteService {
return new NoteService($container->get('note_repository'), $container->get('redis_service'));
};
2 changes: 1 addition & 1 deletion src/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

final class DefaultController extends BaseController
{
public const API_VERSION = '1.1.0';
public const API_VERSION = '1.2.0';

public function __construct(Container $container)
{
Expand Down

0 comments on commit 3a61463

Please sign in to comment.