PHP code example of ifroariquemes / php-api

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

    

ifroariquemes / php-api example snippets


/**
 * @Api("my/route")
 * No @HttpMethod annotation, accepts all HTTP kinds of request methods
 */
public function myRoute() {
    // code
}

/**
 * @Api("route/with/$var")
 * @HttpMethod("PUT") // will accept only PUT requests
 */
public function routeWith($var) {
    // code
}

/**
 * @Api("another/$id/maybe/$var")
 * @HttpMethod("GET,POST") // will accept only GET and POST requests
 */
public function routeAnother($id, $var) {
    // code
}

\PhpApi\PhpApi::start('src'); // your source code directory
apache
AddType application/x-httpd-php .php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
<Files "keys.json">
Order Allow,Deny
Deny from all
</Files>