Skip to content

Commit 07a5986

Browse files
refactored to PHP 8
1 parent 75afab5 commit 07a5986

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+584
-486
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DB_HOST='127.0.0.1'
2-
DB_NAME='rest_api_slim_php'
2+
DB_NAME='php_slim_rest_api'
33
DB_USER='root'
44
DB_PASS=''
55
DB_PORT='3306'

.scrutinizer.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ build:
1717
environment:
1818
variables:
1919
DB_HOST: '127.0.0.1'
20-
DB_NAME: 'rest_api_slim_php'
20+
DB_NAME: 'php_slim_rest_api'
2121
DB_USER: 'root'
2222
DB_PASS: ''
2323
DB_PORT: '3306'
2424
DISPLAY_ERROR_DETAILS: true
25-
APP_DOMAIN: 'https://rest-api-slim-php-sql.herokuapp.com'
25+
APP_DOMAIN: 'https://php-slim-rest-api-sql.herokuapp.com'
2626
SECRET_KEY: 'YourSuperSecret-KeY'
2727
REDIS_ENABLED: true
2828
REDIS_URL: 'localhost'
@@ -32,8 +32,8 @@ build:
3232
project_setup:
3333
before:
3434
- sudo service start mysql || true
35-
- mysql -e "CREATE DATABASE rest_api_slim_php"
36-
- mysql rest_api_slim_php < database/database.sql
35+
- mysql -e "CREATE DATABASE php_slim_rest_api"
36+
- mysql php_slim_rest_api < database/database.sql
3737
override:
3838
- php-scrutinizer-run
3939
-

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: php
22

33
php:
4-
- "7.4.0"
54
- '8.0.0'
65

76
services:
@@ -12,7 +11,7 @@ env:
1211
global:
1312
- CC_TEST_REPORTER_ID=5acc45b5f48d4ca2a5baa0d22ee9a10890b29a76b3ef34a936fdd0ba8c5d7ba8
1413
- DB_HOST=127.0.0.1
15-
- DB_NAME=rest_api_slim_php
14+
- DB_NAME=php_slim_rest_api
1615
- DB_USER=root
1716
- DB_PASS=
1817
- DB_PORT=3306
@@ -24,15 +23,15 @@ env:
2423
- LOGS_ENABLED=true
2524

2625
before_install:
27-
- mysql -e 'CREATE DATABASE rest_api_slim_php;'
26+
- mysql -e 'CREATE DATABASE php_slim_rest_api;'
2827

2928
before_script:
30-
- mysql rest_api_slim_php < database/database.sql
29+
- mysql php_slim_rest_api < database/database.sql
3130
- composer install
3231
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
3332
- chmod +x ./cc-test-reporter
3433
- ./cc-test-reporter before-build
3534

3635
script:
3736
- vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml --whitelist src
38-
- if [ $(phpenv version-name) = "7.4" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
37+
# - if [ $(phpenv version-name) = "8.0" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
Copyright (c) 2020 created by Mauro Bonfietti, edited by Fernando Calmet
3+
Copyright (c) 2020 created by Fernando Calmet
44

55
> Permission is hereby granted, free of charge, to any person obtaining a copy
66
> of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
44
PWD := $(dir $(MAKEPATH))
5-
CONTAINERS := $(shell docker ps -a -q -f "name=rest-api-slim-php*")
5+
CONTAINERS := $(shell docker ps -a -q -f "name=php-slim-rest-api*")
66

77
up:
88
docker-compose up -d --build
@@ -11,20 +11,20 @@ down:
1111
docker-compose down
1212

1313
nginx:
14-
docker exec -it rest-api-slim-php-nginx-container bash
14+
docker exec -it php-slim-rest-api-nginx-container bash
1515

1616
php:
17-
docker exec -it rest-api-slim-php-php-container bash
17+
docker exec -it php-slim-rest-api-php-container bash
1818

1919
phplog:
20-
docker logs rest-api-slim-php-php-container
20+
docker logs php-slim-rest-api-php-container
2121

2222
nginxlog:
23-
docker logs rest-api-slim-php-nginx-container
23+
docker logs php-slim-rest-api-nginx-container
2424

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

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

README.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# REST API IN SLIM PHP 🐘
22

3-
[![License](https://img.shields.io/github/license/fernandocalmet/rest-api-slim-php)](https://github.com/FernandoCalmet/rest-api-slim-php/blob/master/LICENSE.md)
4-
[![Build Status](https://travis-ci.com/FernandoCalmet/rest-api-slim-php.svg?branch=master)](https://travis-ci.com/FernandoCalmet/rest-api-slim-php)
5-
[![Build Status](https://scrutinizer-ci.com/g/FernandoCalmet/rest-api-slim-php/badges/build.png?b=master)](https://scrutinizer-ci.com/g/FernandoCalmet/rest-api-slim-php/build-status/master)
6-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/FernandoCalmet/rest-api-slim-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/FernandoCalmet/rest-api-slim-php/?branch=master)
7-
[![Code Coverage](https://scrutinizer-ci.com/g/FernandoCalmet/rest-api-slim-php/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/FernandoCalmet/rest-api-slim-php/?branch=master)
3+
[![Github][github-shield]][github-url]
4+
[![Kofi][kofi-shield]][kofi-url]
5+
[![LinkedIn][linkedin-shield]][linkedin-url]
6+
[![Khanakat][khanakat-shield]][khanakat-url]
7+
[![License](https://img.shields.io/github/license/fernandocalmet/php-slim-rest-api)](https://github.com/FernandoCalmet/php-slim-rest-api/blob/master/LICENSE.md)
8+
[![Build Status](https://travis-ci.com/FernandoCalmet/php-slim-rest-api.svg?branch=master)](https://travis-ci.com/FernandoCalmet/php-slim-rest-api)
9+
[![Build Status](https://scrutinizer-ci.com/g/FernandoCalmet/php-slim-rest-api/badges/build.png?b=master)](https://scrutinizer-ci.com/g/FernandoCalmet/php-slim-rest-api/build-status/master)
10+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/FernandoCalmet/php-slim-rest-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/FernandoCalmet/php-slim-rest-api/?branch=master)
11+
[![Code Coverage](https://scrutinizer-ci.com/g/FernandoCalmet/php-slim-rest-api/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/FernandoCalmet/php-slim-rest-api/?branch=master)
812
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=FernandoCalmet_rest-api-slim-php&metric=alert_status)](https://sonarcloud.io/dashboard?id=FernandoCalmet_rest-api-slim-php)
9-
[![Code Intelligence Status](https://scrutinizer-ci.com/g/FernandoCalmet/rest-api-slim-php/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
10-
13+
[![Code Intelligence Status](https://scrutinizer-ci.com/g/FernandoCalmet/php-slim-rest-api/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
1114
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=FernandoCalmet_rest-api-slim-php)](https://sonarcloud.io/dashboard?id=FernandoCalmet_rest-api-slim-php)
1215

1316
Principales tecnologías utilizadas: `PHP 7, Slim 3, MySQL, Monolog, Redis, dotenv, PHPUnit y JSON Web Tokens.`
@@ -44,15 +47,15 @@ keys *
4447
FLUSHALL
4548

4649
# Query (example of a cached data):
47-
get "rest-api-slim-php:test:status"
50+
get "php-slim-rest-api:test:status"
4851
```
4952

5053
### Con Composer
5154

5255
Puede crear un nuevo proyecto ejecutando los siguientes comandos:
5356

5457
```bash
55-
composer create-project fernandocalmet/rest-api-slim-php [my-api-name]
58+
composer create-project fernandocalmet/php-slim-rest-api [my-api-name]
5659
cd [my-api-name]
5760
composer restart-db
5861
composer test
@@ -64,7 +67,7 @@ composer start
6467
En su terminal, ejecute estos comandos:
6568

6669
```bash
67-
git clone https://github.com/fernandocalmet/rest-api-slim-php.git && cd rest-api-slim-php
70+
git clone https://github.com/fernandocalmet/php-slim-rest-api.git && cd php-slim-rest-api
6871
cp .env.example .env
6972
composer install
7073
composer restart-db
@@ -180,16 +183,18 @@ Toda la información de la API, preparada para descargar y usar como colección
180183

181184
### OPEN API SPEC
182185

183-
Además, puede ver la especificación de OpenAPI, utilizando [Swagger UI](https://rest-api-slim-php-sql.herokuapp.com/docs/index.html).
186+
Además, puede ver la especificación de OpenAPI, utilizando [Swagger UI](https://php-slim-rest-api-sql.herokuapp.com/docs/index.html).
184187

185188
## :page_facing_up: LICENCIA
186189

187190
Licencia MIT. Puedes verla en el [Archivo de Licencia](LICENSE.md) para más información.
188191

189-
[Autor](https://github.com/maurobonfietti) de la base de este proyecto, y modificado por el [colaborador](https://github.com/fernandocalmet).
190-
191-
---
192-
193-
:octocat: [Puedes seguirme en Github.](https://github.com/FernandoCalmet)
194-
195-
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/T6T41JKMI)
192+
<!--- reference style links --->
193+
[github-shield]: https://img.shields.io/badge/-@fernandocalmet-%23181717?style=flat-square&logo=github
194+
[github-url]: https://github.com/fernandocalmet
195+
[kofi-shield]: https://img.shields.io/badge/-@fernandocalmet-%231DA1F2?style=flat-square&logo=kofi&logoColor=ff5f5f
196+
[kofi-url]: https://ko-fi.com/fernandocalmet
197+
[linkedin-shield]: https://img.shields.io/badge/-fernandocalmet-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/fernandocalmet
198+
[linkedin-url]: https://www.linkedin.com/in/fernandocalmet
199+
[khanakat-shield]: https://img.shields.io/badge/khanakat.com-brightgreen?style=flat-square
200+
[khanakat-url]: https://khanakat.com

app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "rest-api-slim-php",
2+
"name": "php-slim-rest-api",
33
"description": "Slim4 Restful CRUD Application",
4-
"repository": "https://github.com/fernandocalmet/rest-api-slim-php",
5-
"logo": "https://raw.githubusercontent.com/fernandocalmet/rest-api-slim-php/master/extras/img/php-logo.jpg",
4+
"repository": "https://github.com/fernandocalmet/php-slim-rest-api",
5+
"logo": "https://raw.githubusercontent.com/fernandocalmet/php-slim-rest-api/master/extras/img/php-logo.jpg",
66
"keywords": ["php", "slim-micro-framework", "rest-api", "mysql", "slim3", "slim", "rest", "api"]
77
}

composer.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "fernandocalmet/rest-api-slim-php",
3-
"description": "Rest API Slim PHP SQL",
2+
"name": "fernandocalmet/php-slim-rest-api",
3+
"description": "Rest API with Slim PHP Framework",
44
"keywords": [
55
"php",
66
"slim-micro-framework",
@@ -11,7 +11,7 @@
1111
"rest",
1212
"api"
1313
],
14-
"homepage": "https://github.com/fernandocalmet/rest-api-slim-php",
14+
"homepage": "https://github.com/fernandocalmet/php-slim-rest-api",
1515
"license": "MIT",
1616
"authors": [
1717
{
@@ -23,8 +23,8 @@
2323
"minimum-stability": "dev",
2424
"prefer-stable": true,
2525
"require": {
26-
"php": "^7.4 || ^8.0",
27-
"composer/composer": "1.10.23",
26+
"php": "^8.0",
27+
"composer/composer": "^2.0",
2828
"firebase/php-jwt": "^5.0",
2929
"monolog/monolog": "^2.0@dev",
3030
"palanik/corsslim": "dev-slim3",
@@ -34,17 +34,20 @@
3434
"vlucas/phpdotenv": "^5.1"
3535
},
3636
"require-dev": {
37-
"nunomaduro/phpinsights": "^1.14",
37+
"nunomaduro/phpinsights": "^2.0",
3838
"pestphp/pest": "^1.7",
39-
"phpstan/phpstan": "^0.12",
39+
"phpstan/phpstan": "^1.2",
4040
"phpunit/phpunit": "^9.0",
41-
"vimeo/psalm": "^3.15"
41+
"rector/rector": "^0.12.4",
42+
"vimeo/psalm": "^4.18"
4243
},
4344
"config": {
4445
"sort-packages": true,
4546
"process-timeout" : 0,
46-
"platform": {
47-
"php": "7.4.0"
47+
"allow-plugins": {
48+
"pestphp/pest-plugin": true,
49+
"composer/package-versions-deprecated": true,
50+
"dealerdirect/phpcodesniffer-composer-installer": true
4851
}
4952
},
5053
"autoload": {

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: '3'
33
services:
44
nginx:
55
image: nginx:latest
6-
container_name: rest-api-slim-php-nginx-container
6+
container_name: php-slim-rest-api-nginx-container
77
ports:
88
- "8081:80"
99
volumes:
@@ -12,7 +12,7 @@ services:
1212

1313
php-fpm:
1414
build: ./docker/php7
15-
container_name: rest-api-slim-php-php-container
15+
container_name: php-slim-rest-api-php-container
1616
links:
1717
- mysql
1818
- redis
@@ -22,7 +22,7 @@ services:
2222
- PHP_FPM_SERVER_PORT=9000
2323
- PHP_FPM_TIMEOUT=${HTTPD_TIMEOUT_TO_PHP_FPM:-180}
2424
- DB_HOST=mysql
25-
- DB_NAME=rest_api_slim_php
25+
- DB_NAME=php_slim_rest_api
2626
- DB_USER=root
2727
- DB_PASS=
2828
- DB_PORT=3306
@@ -44,7 +44,7 @@ services:
4444
- 33060:3306
4545
environment:
4646
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
47-
MYSQL_DATABASE: rest_api_slim_php
47+
MYSQL_DATABASE: php_slim_rest_api
4848
MYSQL_USER: root
4949
MYSQL_PASSWORD:
5050
MYSQL_ROOT_PASSWORD:

docker/dev-tools/update-docker-hostnames.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
ETC_HOSTS=/etc/hosts
44

55
declare -a IPS=(
6-
"`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' rest-api-slim-php-nginx-container`"
6+
"`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' php-slim-rest-api-nginx-container`"
77
)
88

99
declare -a HOSTNAMES=(
10-
"rest-api-slim-php.docker.local"
10+
"php-slim-rest-api.docker.local"
1111
)
1212

1313
removehosts() {

0 commit comments

Comments
 (0)