2017 © Pedro Peláez
 

library php-api

PHP API Utilities

image

hugsbrugs/php-api

PHP API Utilities

  • Wednesday, December 20, 2017
  • by hugsbrugs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

php-api

This librairy provides utilities function to group different API calls for a single project entry point. Based on Tonic., (*1)

Install

Install package with composer, (*2)

composer require hugsbrugs/php-api

In your PHP code, load library, (*3)

require_once __DIR__ . '/../vendor/autoload.php';
use Hug\Api\Api as Api;

Usage

Edit config.php

Set your parameters. Visit Tonic documentation for params., (*4)

Put dispatch.php and .htaccess files in api folder

If you want to access your API through /api subfolder, create this folder at your webroot directory and copy .htaccess (which will redirect all traffic to dispatch.php) and dispatch.php (which will route your API requests), (*5)

Create your API classes

Look at TestApi.php and create your API endpoints extending, (*6)

Hug\Api\ApiResource

Based on Tonic syntax, (*7)

Consume your API

In your browser visit your endpoints or do CURL requests to test POST, PUT, DELETE methods., (*8)

Changelog

28/09/2023 - Migration for PHP 8 Replace "peej/tonic" : "dev-master", By "neekfenwick/tonic" : "^3.4.1",, (*9)

Author

Hugo Maugey visit my website ;), (*10)

The Versions