PHP code example of devfactory / api

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

    

devfactory / api example snippets


'providers' => array(
  'Devfactory\Api\ApiServiceProvider',
),

alias => array(
    'API'          => 'Devfactory\Api\Facades\ApiFacade',
),

Route::group(array('prefix' => 'v1'), function()
{
    Route::get('foo.{format}', 'ApiV1\FooController@foo');
    Route::post('bar.{format}', 'ApiV1\FooController@bar');
});

Route::group(array('prefix' => '{format}/v1'), function()
{
    Route::get('foo', 'ApiV1\FooController@foo');
    Route::post('bar', 'ApiV1\FooController@bar');
});

  return Response::api(array("foo" => "bar"), 404);
  return Response::api(array("ok"));

  return API::createResponse(array("foo" => "bar"), 404);
  return API::createResponse(array("ok"));

  API::get('v1/foo.json', array('foo' => 'bar'));
  API::post('v1/bar.xml', array('foo' => 'bar'));
  API::put('v1/bar.xml', array('foo' => 'bar'));

 php artisan config:publish devfactory/api