Skip to content

Aphpi/aphpi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aphpi Template

Starter Template for PHP APIs

Installation

Installer

First, download the installer using Composer:

composer global require aphpi/installer

Make sure to place Composer's system-wide vendor bin directory in your $PATH so the aphpi executable can be located by your system. This directory exists in different locations based on your operating system; however, some common locations include:

  • macOS: $HOME/.composer/vendor/bin
  • Windows: %USERPROFILE%\AppData\Roaming\Composer\vendor\bin
  • GNU / Linux Distributions: $HOME/.config/composer/vendor/bin or $HOME/.composer/vendor/bin

You could also find the composer's global installation path by running composer global about and looking up from the first line.

Once installed, the aphpi new command will create a fresh aphpi installation in the directory you specify.

aphpi new github-api Your\\Namespace\\Github

Manual

git clone https://github.com/aphpi/aphpi.git example-api
cd example-api
composer install

Replace "Aphpi\Template" with your namespace in all files:

  • src/*/.php
  • tests/*/.php
  • composer.json

Usage

  1. Update Api->getClient

src/Api.php

protected function getClient() : Client
{
    return new Client([        
        'base_uri' => 'http://httpbin.org',
        'timeout'  => 2.0,
    ]);
}
  1. Create Endpoints in src/Endpoints
  2. Set Endpoint in Api.php

src/Api.php

protected function setEndpoints(Client $client) : void
{
    $this->example = new Example($client);
}
  1. Make Call
$api = new Api();
$response = $api->example->post();

About

Starter Template for PHP APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages