PHP code example of alexoliverwd / simple-api

1. Go to this page and download the library: Download alexoliverwd/simple-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alexoliverwd / simple-api example snippets




namespace APIExample;

use AOWD\SimpleAPI\Methods;
use AOWD\SimpleAPI\Status;
use AOWD\SimpleAPI\API;

// Load dependencies
outes
 * @return void
 */
function registerRoutes(): void
{
    // Register index page GET request
    API::registerRoute(Methods::GET, '/api/', '\APIExample\home');
}

/**
 * Process API home endpoint
 * @return never
 */
function home(): never
{
    API::sendMessage(
        messages: ['Success'],
        status: Status::Success,
        response_code: 200
    );
}

// Run API
API::init();
index.php