PHP code example of rawebone / wilson

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

    

rawebone / wilson example snippets




// File: public/index.php

esources = array("My\Restful\ResourceA");
$api->dispatch();




// File: src/My/Restful/ResourceA.php

namespace My\Restful;

class ResourceA
{
    /**
     * @route GET /resource-a/
     */
    function getCollection($request, $response, $services)
    {
        $response->json(array("a", "b", "c"));
    }
    
    /**
     * @route GET /resource-a/{file}.md
     * @where file [a-z]+
     */
    function getRecord($request, $response, $services)
    {
        $response->setBody(get_file($request->getParam("file")));
        $response->setHeader("Content-Type", "text/plain");
    }
}