2017 © Pedro Peláez
 

package api-connector

An interface for Laravel 5 to consume and cache API's data

image

waavi/api-connector

An interface for Laravel 5 to consume and cache API's data

  • Friday, January 19, 2018
  • by jamesalways
  • Repository
  • 3 Watchers
  • 0 Stars
  • 53 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Api Connector

A Laravel package to consume and cache API calls., (*1)

WAAVI is a web development studio based in Madrid, Spain. You can learn more about us at waavi.com, (*2)

Installing

Require through Composer, (*3)

composer require waavi/api-connector dev-master

Or manually edit your composer.json file, (*4)

"require": {
    "waavi/api-connector": "dev-master"
}

Configuration

Once installed, edit your config/app.php add the following entry to the providers array:, (*5)

Waavi\ApiConnector\ApiConnectorServiceProvider::class

Usage

Once installed and configured you will be able to make API calls using the ApiConnector interface like so:, (*6)

<?php

namespace App\Http\Controllers;

use Waavi\ApiConnector\ApiConnector;

class HomeControllerController extends Controller
{
    protected $connector;

    public function __construct(ApiConnector $connector)
    {
        $this->connector = $connector;
    }

    public function index()
    {
        // A GET call to https://someapi.com/v1/resource
        $resourcesList = $this->connector->get('resource');

        // A GET call to https://someapi.com/v1/resource?size=20&page=3
        $otherResourcesList = $this->connector->get('resource', ['size=20', 'page=3']);

        // A GET call to https://someapi.com/v1/resource/{id}
        $resource = $this->connector->get('resource/1');

        return view('web.home')->with(compact('resourcesList', 'otherResourcesList', 'resource'));
    }
}

By default, the calls will be cached and retrieved from the cache on subsequent calls. If you wish to disable this behaviour just edit your config., (*7)

Built With

License

This project is licensed under the MIT License - see the LICENSE.md file for details, (*8)

xkcd because yes

IMAGE, (*9)

The Versions

19/01 2018

dev-master

9999999-dev

An interface for Laravel 5 to consume and cache API's data

  Sources   Download

MIT

The Requires

 

by Sergio Uve

laravel api cache waavi

15/01 2018

dev-develop

dev-develop

An interface for Laravel 5 to consume and cache API's data

  Sources   Download

MIT

The Requires

 

by Sergio Uve

laravel api cache waavi