/PHP-API-Boilerplate

🐘 A RESTful PHP API with 🔐JWT and 📫Mailer, so you won't need to code everything everytime I create a new project.

Primary LanguagePHP

PHP API Boilerplate


Requirements

  • PHP 7.1
  • OpenSSL PHP extension (for certain algorithms)

Installation:

Install composer if you haven't: https://getcomposer.org/download

  1. In main directory, run this php command to install all dependencies: php composer.phar install
  2. Rename config.php.example to config.php and set your own configurations.

Using API:

This project is using single file API: api.php
Example:
http://localhost/my_api/api.php/register --> for registing new user.
http://localhost/my_api/api.php/get/users --> will retrieve all rows in users table.

  • Request is always using POST method. For CRUD, set token at Authorization on request header.
    Authorization: Bearer MY_SECRET_TOKEN
  • For registration set Content-Type:application/x-www-form-urlencoded on request header.

Sending email:

Just use sendEmail() function to send an email. sendEmail($to, $subject, $htmlBody)


This repository is using: