PHP code example of helllomatt / aspen

1. Go to this page and download the library: Download helllomatt/aspen 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/ */

    

helllomatt / aspen example snippets




namespace ASPEN;

 in enabling CORS
// Config::checkOrigin(Config::getOriginInformation());

Config::load('path/to/config.json');
$manager = new APIManager();
$manager->load([
    'modules/endpoint1',
    'modules/endpoint2'
]);



use ASPEN\API;
use ASPEN\Response;

$api = new API('Sample'); // API name (not really important)
$api->version(1);         // API version (important)

// API endpoints
$api->add((new Endpoint([
        'to'     => 'test/'
        'method' => 'get'
    ]))->then(function(Response $r) {
        $r->add("hello", "world");
        $r->success();
    }))

return $api; // VERY IMPORTANT!

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?route=$1 [QSA]