https://github.com/maurobonfietti/slim4-api-skeleton
Useful skeleton for RESTful API development with PHP and Slim 4.
https://github.com/maurobonfietti/slim4-api-skeleton
api-skeleton mysql php rest-api slim slim-micro-framework
Last synced: 9 days ago
JSON representation
Useful skeleton for RESTful API development with PHP and Slim 4.
- Host: GitHub
- URL: https://github.com/maurobonfietti/slim4-api-skeleton
- Owner: maurobonfietti
- License: mit
- Created: 2019-08-01T02:32:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-30T16:26:21.000Z (about 1 year ago)
- Last Synced: 2025-09-20T05:45:33.213Z (3 months ago)
- Topics: api-skeleton, mysql, php, rest-api, slim, slim-micro-framework
- Language: PHP
- Homepage: http://bit.ly/2nNNOZi
- Size: 396 KB
- Stars: 137
- Watchers: 7
- Forks: 35
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# SLIM 4 - API SKELETON
Useful skeleton for RESTful API development, using [Slim PHP micro-framework](https://www.slimframework.com).
[![Software License][ico-license]](LICENSE.md)
[](https://travis-ci.com/maurobonfietti/slim4-api-skeleton)
[](https://coveralls.io/github/maurobonfietti/slim4-api-skeleton?branch=master)
[](https://packagist.org/packages/maurobonfietti/slim4-api-skeleton)
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat
## 💻 TECHNOLOGIES USED:
The main technologies used in this project are:
- PHP 8
- Slim 4
- MySQL
- PHPUnit
- dotenv
- Docker
- Docker Compose
## ⚙️ QUICK INSTALL:
### Requirements:
- Composer.
- PHP >= 8.1
- MySQL/MariaDB.
- or Docker.
### With Composer:
You can create a new project running the following commands:
```bash
composer create-project maurobonfietti/slim4-api-skeleton [my-api-name]
cd [my-api-name]
composer test
composer start
```
#### Configure your connection to MySQL Server:
By default, the API uses a MySQL database.
You should check and edit this configuration in your `.env` file:
```
DB_HOST='127.0.0.1'
DB_NAME='yourMySqlDatabase'
DB_USER='yourMySqlUsername'
DB_PASS='yourMySqlPassword'
DB_PORT='3306'
```
### With Docker:
If you like Docker, you can use this project with **Docker** and **Docker Compose**.
**Minimal Docker Version:**
* Engine: 18.03+
* Compose: 1.21+
**Docker Commands:**
```bash
# Create and start containers for the API.
docker-compose up -d --build
# Checkout the API.
curl http://localhost:8081
# Stop and remove containers.
docker-compose down
```
## 📦 DEPENDENCIES:
### LIST OF REQUIRE DEPENDENCIES:
- [slim/slim](https://github.com/slimphp/Slim): Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
- [slim/psr7](https://github.com/slimphp/Slim-Psr7): PSR-7 implementation for use with Slim 4.
- [pimple/pimple](https://github.com/silexphp/Pimple): A small PHP dependency injection container.
- [vlucas/phpdotenv](https://github.com/vlucas/phpdotenv): Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
### LIST OF DEVELOPMENT DEPENDENCIES:
- [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit): The PHP Unit Testing framework.
- [symfony/console](https://github.com/symfony/console): The Console component eases the creation of beautiful and testable command line interfaces.
- [nunomaduro/phpinsights](https://github.com/nunomaduro/phpinsights): Instant PHP quality checks from your console.
- [maurobonfietti/slim4-api-skeleton-crud-generator](https://github.com/maurobonfietti/slim4-api-skeleton-crud-generator): CRUD Generator for Slim 4 - Api Skeleton.
## 🔖 ENDPOINTS:
### BY DEFAULT:
- Hello: `GET /`
- Health Check: `GET /status`
## 📹 TUTORIAL:
Learn how to develop a RESTful API with PHP and Slim 4 by following this [video](https://youtu.be/DetK1w65S-k) [🎥 🔈 🇪🇸 🇦🇷]
https://user-images.githubusercontent.com/24535949/180607903-7efd2cfc-b1df-4ad6-8295-801585df3b83.mp4
## :heart: SUPPORT THE PROJECT
If you would like to support this project, you can:
- Invite the author a coffee :coffee: :yum:
- Give a star to the repository :star: :blush:
[](https://ko-fi.com/maurobonfietti)
## :sunglasses: AND THAT'S IT!
Now, go to build an excellent RESTful API.