2017 © Pedro Peláez
 

library api

RESTful API package

image

devfactory/api

RESTful API package

  • Wednesday, March 9, 2016
  • by devfactory
  • Repository
  • 5 Watchers
  • 1 Stars
  • 578 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Api

Helpers to create an API for laravel 4.2, (*1)

This module handle json and xml as response, (*2)

Latest Stable Version Total Downloads License, (*3)

How to setup

update composer.json file:, (*4)

{
    "require": {
        "devfactory/api": "1.0.*"
    }
}

and run composer update from terminal to download files., (*5)

update app.php file in app/config directory:, (*6)

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

Configuration

 php artisan config:publish devfactory/api

How to use api

in your route, (*7)

the param {format} are not mandatory, (*8)

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');
});

In you controller you can use, (*9)

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

or, (*10)

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

To call your service you can use the Facade

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

The Versions

09/03 2016

dev-master

9999999-dev

RESTful API package

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api rest laravel 4 restful

09/03 2016

1.0.5

1.0.5.0

RESTful API package

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api rest laravel 4 restful

15/12 2014

1.0.4

1.0.4.0

RESTful API package

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api rest laravel 4 restful

09/12 2014

1.0.3

1.0.3.0

RESTful API package

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api rest laravel 4 restful

09/12 2014

1.0.2

1.0.2.0

RESTful API package

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api rest laravel 4 restful

08/12 2014

1.0.1

1.0.1.0

RESTful API package

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api rest laravel 4 restful

08/12 2014

1.0.0

1.0.0.0

RESTful API package

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api rest laravel 4 restful