PHP code example of dot-env-it / laravel-api-integrator

1. Go to this page and download the library: Download dot-env-it/laravel-api-integrator 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/ */

    

dot-env-it / laravel-api-integrator example snippets


use DotEnvIt\ApiIntegrator\Facades\Integration;

//api url https://api.github.com/foo
Integration::for('github')->get('foo')->json();

//api url https://api.example.com/foo
Integration::for('example')->get('foo')->json();

use DotEnvIt\ApiIntegrator\Facades\Integration;

//api url https://api.example.com/foo
Integration::for('example')->getFoo()->json();

//api url https://api.example.com/foo with dynamic token
Integration::for('example')->withToken('new-token')->getFoo()->json();

//api url https://api.example.com/foo with dynamic header
Integration::for('example')->withHeader('X-CUSTOM-HEADER', 'CUSTOM')->withHeader('X-CUSTOM-HEADER-2', 'CUSTOM-2')->getFoo()->json();

//api url https://api.example.com/foo with headers array
Integration::for('example')->withHeaders(['X-CUSTOM-HEADER' => 'CUSTOM', 'X-CUSTOM-HEADER-2' => 'CUSTOM-2'])->getFoo()->json();

//api url https://api.example.com/foo/1
Integration::for('example')->getFoo_id(['id' => 1])->json();

//api url https://api.example.com/foo/1/bar/2
Integration::for('example')->getFoo_foo_id_bar_bar_id(['foo_id' => 1, 'bar_id' => 2])->json();

//api url https://api.example.com/foo/1?foo=bar&bar=baz
Integration::for('example')->getFoo_id(['id' => 1, 'foo' => 'bar', 'bar' => 'baz'])->json();

//POST api url https://api.example.com/foo/1/bar/2/baz
Integration::for('example')->postFoo_foo_id_bar_bar_id_baz(['foo_id' => 1, 'bar_id' => 2])->json();
bash
php artisan api-integrator:install