PHP code example of kielabokkie / laravel-apise

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

    

kielabokkie / laravel-apise example snippets


return [
    /**
     * The namespace where your API Service classes are created under.
     * This will be appended to your base namespace. So the config below
     * will create a class under App\Support\Services.
     */
    'namespace' => 'Support\Services',

    /**
     * These middlewares will be assigned to the Apise routes. You can
     * add your own middleware to this list or change any of the existing
     * middleware.
     */
    'middleware' => [
        'web',
        Authorize::class,
    ],

    /**
     * Enable logging of requests and responses
     */
    'logging_enabled' => env('APISE_LOGGING_ENABLED', true),

    /**
     * Enable concealing of sensitive data
     */
    'conceal_enabled' => env('APISE_CONCEAL_ENABLED', true),

    /**
     * Keys that should be concealed when displayed on the Apise UI
     */
    'conceal_keys' => [
        'api_key'
    ]

    /**
     * This is the URI path where the UI will be accessible from
     */
    'path' => env('APISE_PATH', 'apise'),
];

'conceal_keys' => [
    'api_key',
    'Authorization',
    'token'
]



namespace App\Support\Services;

use Kielabokkie\Apise\ApiseClient;

class HttpBinService extends ApiseClient
{
    protected $baseUrl = 'https://httpbin.org';

    public function __construct()
    {
        $this->setClient();
    }
}

public function getUsers()
{
    $response = $this->get('/users'));

    return json_decode($response->getBody());
}

protected function defaultHeaders()
{
    return [
        'Authorization' => 'Bearer abcdef123456',
    ];
}

protected function defaultQueryParams()
{
    return [
        'token' => 'your-token'
    ];
}

protected function schedule(Schedule $schedule)
{
    // Clean up logs older than 3 days
    $schedule->command('apise:prune --hours=72')
         ->daily();
}
bash
php artisan apise:install
bash
php artisan migrate
bash
php artisan vendor:publish --tag=apise-assets

APISE_PATH='admin/apise'
bash
php artisan make:api-service HttpBinService
bash
php artisan apise:prune --hours 24