Retrieving data from a REST api without HTTP request.

1.0.0 2016-12-09 04:06 UTC

This package is not auto-updated.

Last update: 2024-04-13 17:52:01 UTC


Consume your own API from the same application without request via HTTP protocol


To get the latest version of Consume simply require it in your composer.json file.

"teepluss/consume": "^1.0.0"

You'll then need to run composer install to download it and have the autoloader updated.

Once Consume is installed you need to register the service provider with the application. Open up config/app.php and find the providers key.

'providers' => [



Consume also ships with a facade which provides the static syntax for creating collections. You can register the facade in the aliases key of your config/app.php file.

'aliases' => [

    'Consume' => Teepluss\Consume\Facades\Consume::class,



$accessToken = "[YOUR_ACCESS_TOKEN]";

// File uploading.
$userfile = request()->file('userfile');

// POST parameters.
$parameters = [
    'name'     => 'Teepluss',
    'userfile' => $userfile

try {
    $request = Consume::asJson()
                      ->request('POST', '/api/user', $parameters)

    $response = $request->getContent();
} catch (\Teepluss\Consume\Exception\ErrorException $e) {
    // This may return laravel validation error.
    $response = $e->getContent();
} catch (\Teepluss\Consume\Exception\NotFoundException $e) {
    $response = 'Not Found Exception';


If you are sending file upload to the REST api you need to get file directly.

// Not work

// work

Support or Contact

If you have any problems, Contact teepluss@gmail.com

Support via PayPal