maurobonfietti/rest-api-slim-php
소개
Slim PHP 마이크로 프레임워크를 사용한 REST API 예제입니다.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalREST API IN SLIM PHP
This is an example of a RESTful API built using the Slim PHP micro-framework.
The API allows you to manage resources such as users, tasks, and notes.
You can also read this README IN SPANISH.

🖥️ TECHNOLOGIES USED:
The leading technologies used in this project are:
- PHP 8.6
- Slim 4
- MySQL
- Redis
- dotenv
- PHPUnit
- JSON Web Tokens (JWT)
Additional tools:
Also, I use other additional tools like:
- Docker & Docker Compose
- Swagger
- Code Climate
- Scrutinizer
- Sonar Cloud
- PHPStan
- PHP Insights
- Heroku
- CORS
⚙️ QUICK INSTALL:
Requirements:
- Git
- Composer
- PHP >= 8.6
- MySQL/MariaDB
- Redis (Optional)
- or Docker
With Composer:
You can create a new project running the following commands:
$ composer create-project maurobonfietti/rest-api-slim-php [my-api-name]
$ cd [my-api-name]
$ composer restart-db
$ composer test
$ composer start
With Git:
In your terminal, execute these commands:
$ git clone https://github.com/maurobonfietti/rest-api-slim-php.git && cd rest-api-slim-php
$ cp .env.example .env
$ composer install
$ composer restart-db
$ composer test
$ composer start
With Docker:
You can use this project using docker and docker-compose.
Minimal Docker Version:
- Engine: 18.03+
- Compose: 1.21+
Commands:
# Start the API (this is my alias for: docker-compose up -d --build).
$ make up
# To create the database and import test data from scratch.
$ make db
# Checkout the API.
$ curl http://localhost:8081
# Stop and remove containers (it's like: docker-compose down).
$ make down
🛠️ TROUBLESHOOTING:
If you get stuck, you can try this guide step by step.
🎦 TUTORIALS:
Watch this mini-series of videos about Slim PHP (Spanish Audio :sound: :es: :argentina:).
:video_camera: VIDEO #1
How to install and configure this API.
:movie_camera: VIDEO #2
How to use JWT for Authentication.
:video_camera: VIDEO #3
:movie_camera: VIDEO #4
📦 DEPENDENCIES:
LIST OF REQUIRE DEPENDENCIES:
- slim/slim: Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
- respect/validation: The most awesome validation engine ever created for PHP.
- palanik/corsslim: Cross-origin resource sharing (CORS) middleware for PHP Slim.
- vlucas/phpdotenv: Loads environment variables from
.envtogetenv(),$_ENVand$_SERVERautomagically. - predis/predis: Flexible and feature-complete Redis client for PHP and HHVM.
- firebase/php-jwt: A simple library to encode and decode JSON Web Tokens (JWT) in PHP.
LIST OF DEVELOPMENT DEPENDENCIES:
- phpunit/phpunit: The PHP Unit Testing framework.
- phpstan/phpstan: PHPStan - PHP Static Analysis Tool.
- nunomaduro/phpinsights: Instant PHP quality checks from your console.
- vimeo/psalm: A static analysis tool for finding errors in PHP applications.
- rector/rector: Instant Upgrades and Instant Refactoring of any PHP 5.3+ code.
🚥 TESTING:
Run all PHPUnit tests with composer test.
$ composer test
> phpunit
PHPUnit 9.6.38 by Sebastian Bergmann and contributors.
............................................................ 60 / 60 (100%)
Time: 00:00.821, Memory: 16.00 MB
OK (60 tests, 364 assertions)
📸 SCREENSHOOTS:


📚 DOCUMENTATION:
ENDPOINTS:
INFO:
Help:
GET /Status:
GET /status
USERS:
Login User:
POST /loginCreate User:
POST /api/v1/usersUpdate User:
PUT /api/v1/users/{id}Delete User:
DELETE /api/v1/users/{id}
TASKS:
Get All Tasks:
GET /api/v1/tasksGet One Task:
GET /api/v1/tasks/{id}Create Task:
POST /api/v1/tasksUpdate Task:
PUT /api/v1/tasks/{id}Delete Task:
DELETE /api/v1/tasks/{id}
NOTES:
Get All Notes:
GET /api/v1/notesGet One Note:
GET /api/v1/notes/{id}Create Note:
POST /api/v1/notesUpdate Note:
PUT /api/v1/notes/{id}Delete Note:
DELETE /api/v1/notes/{id}
Also, you can see the API documentation with the complete list of endpoints.
IMPORT WITH POSTMAN:
All the API information is prepared for download and use as Postman collection: Import Collection.
🚀 DEPLOY:
You can deploy this API with Heroku.
ℹ️ MORE INFORMATION:
For more information about this project, check out my blog post: How to create a REST API using Slim PHP.
You can also look at the to-do list web app I developed using this API in Angular.
💬 CONTRIBUTING:
If you would like to contribute to the project, please open an issue or submit a pull request. Contributions are always welcome!
:heart: DO YOU LIKE THE PROJECT?
You can support this project by inviting me a coffee :coffee: :yum: or giving a star to this repo :star: :sunglasses:.
:page_facing_up: LICENSE
The MIT License (MIT). Please see License File for more information.
관련 프로젝트 살펴보기
불러오는 중…
