All Projects → maurobonfietti → Rest Api Slim Php

maurobonfietti / Rest Api Slim Php

Licence: mit
Example of REST API with Slim PHP Framework.

Projects that are alternatives of or similar to Rest Api Slim Php

Magic
Create your .Net Core/Angular/Database CRUD Web apps by simply clicking a button
Stars: ✭ 214 (+29.7%)
Mutual labels:  api, rest-api, rest, mysql
Http restful api
整理HTTP后台端的RESTful API方面的知识
Stars: ✭ 94 (-43.03%)
Mutual labels:  api, rest-api, rest
Tiledesk Server
Tiledesk server. Tiledesk is an Open Source Live Chat platform written in NodeJs and MongoDB
Stars: ✭ 94 (-43.03%)
Mutual labels:  api, rest-api, rest
Appkernel
API development made easy: a smart Python 3 API framework
Stars: ✭ 152 (-7.88%)
Mutual labels:  api, rest-api, rest
Cookiecutter Django Rest
Build best practiced apis fast with Python3
Stars: ✭ 1,108 (+571.52%)
Mutual labels:  api, rest-api, rest
Acf To Rest Api
Exposes Advanced Custom Fields Endpoints in the WordPress REST API
Stars: ✭ 1,152 (+598.18%)
Mutual labels:  api, rest-api, rest
Json Serverless
Transform a JSON file into a serverless REST API in AWS cloud
Stars: ✭ 108 (-34.55%)
Mutual labels:  api, rest-api, rest
Githubapi
Swift implementation of Github REST API v3
Stars: ✭ 55 (-66.67%)
Mutual labels:  api, rest-api, rest
Open Rest
Standard rest server, Base on restify and sequelize
Stars: ✭ 136 (-17.58%)
Mutual labels:  api, rest-api, rest
Poloniex Api Node
Poloniex API client for REST and WebSocket API
Stars: ✭ 138 (-16.36%)
Mutual labels:  api, rest-api, rest
Jda
Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Stars: ✭ 2,598 (+1474.55%)
Mutual labels:  api, rest-api, rest
Rest Hapi
🚀 A RESTful API generator for Node.js
Stars: ✭ 1,102 (+567.88%)
Mutual labels:  api, rest-api, rest
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+6344.85%)
Mutual labels:  api, rest-api, rest
Apy
Apy is a simple client-side library for making rest api ajax calls.
Stars: ✭ 68 (-58.79%)
Mutual labels:  api, rest-api, rest
Api Strategy
Equinor API Strategy
Stars: ✭ 56 (-66.06%)
Mutual labels:  api, rest-api, rest
Airdcpp Webclient
Communal peer-to-peer file sharing application for file servers/NAS devices
Stars: ✭ 106 (-35.76%)
Mutual labels:  api, rest-api, rest
Node Express Mongoose Passport Jwt Rest Api Auth
Node, express, mongoose, passport and JWT REST API authentication example
Stars: ✭ 146 (-11.52%)
Mutual labels:  api, rest-api, rest
Rest Control
Framework for testing and validation REST services
Stars: ✭ 51 (-69.09%)
Mutual labels:  api, rest-api, rest
Json Api Dart
JSON:API client for Dart/Flutter
Stars: ✭ 53 (-67.88%)
Mutual labels:  api, rest-api, rest
Rest Api Fuzz Testing
REST API Fuzz Testing (RAFT): Source code for self-hosted service developed for Azure, including the API, orchestration engine, and default set of security tools (including MSR's RESTler), that enables developers to embed security tooling into their CI/CD workflows
Stars: ✭ 119 (-27.88%)
Mutual labels:  api, rest-api, rest

REST API IN SLIM PHP

Example of RESTful API with Slim PHP micro framework.

This simple API allows you to manage resources such as: users, tasks and notes.

Software License Build Status Quality Gate Status Code Quality Test Coverage Packagist Version

alt text

You can also read this README IN SPANISH.

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 and CORS.

More info about this project in my post: How to create a REST API using Slim PHP.

I implemented this API in this project. It's a todo list web app developed in Angular.

⚙️ QUICK INSTALL:

Requirements:

  • Git.
  • Composer.
  • PHP 7.4+.
  • 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

How to install

With Git:

In your terminal execute this 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:

Mini-series of videos about Slim PHP (Spanish Audio 🔉 🇪🇸 🇦🇷).

📹 VIDEO #1

How to install and configure this API.

🎥 VIDEO #2

How to use JWT for Authentication.

📹 VIDEO #3

Using Redis Cache.

🎥 VIDEO #4

Deploy Slim PHP on Heroku.

📦 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 .env to getenv(), $_ENV and $_SERVER automagically.
  • 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:

🚥 TESTING:

Run all PHPUnit tests with composer test.

$ composer test
> phpunit
PHPUnit 9.5.1 by Sebastian Bergmann and contributors.

........................................................          56 / 56 (100%)

Time: 00:00.277, Memory: 16.00 MB

OK (56 tests, 343 assertions)

📚 DOCUMENTATION:

ENDPOINTS:

INFO:

  • Help: GET /

  • Status: GET /status

USERS:

  • Login User: POST /login

  • Create User: POST /api/v1/users

  • Update User: PUT /api/v1/users/{id}

  • Delete User: DELETE /api/v1/users/{id}

TASKS:

  • Get All Tasks: GET /api/v1/tasks

  • Get One Task: GET /api/v1/tasks/{id}

  • Create Task: POST /api/v1/tasks

  • Update Task: PUT /api/v1/tasks/{id}

  • Delete Task: DELETE /api/v1/tasks/{id}

NOTES:

  • Get All Notes: GET /api/v1/notes

  • Get One Note: GET /api/v1/notes/{id}

  • Create Note: POST /api/v1/notes

  • Update Note: PUT /api/v1/notes/{id}

  • Delete Note: DELETE /api/v1/notes/{id}

Also, you can see the API documentation with the full list of endpoints.

HELP AND DOCS:

For more information on how to use the REST API, see the following documentation available on Postman Documenter.

IMPORT WITH POSTMAN:

All the information of the API, prepared to download and use as postman collection: Import Collection.

Run in Postman

OPEN API SPEC:

Also, you can view the OpenAPI Specification, using Swagger UI.

🚀 DEPLOY:

You can deploy this API with Heroku Free.

Deploy

🎮 GIVE IT A TRY:

Check it out to this LIVE DEMO.

❤️ DO YOU LIKE THE PROJECT?

You can support this project inviting me a coffee ☕️ 😋 or giving a star to this repo ⭐️ 😎.

Buy Me a Coffee at ko-fi.com

📄 LICENSE

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].