PHPackages                             kielabokkie/laravel-apise - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. kielabokkie/laravel-apise

ActiveLibrary[API Development](/categories/api)

kielabokkie/laravel-apise
=========================

A base class for interacting with external APIs via Guzzle

v1.0.1(5y ago)3226[18 PRs](https://github.com/kielabokkie/laravel-apise/pulls)MITPHPPHP ^7.2

Since Oct 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kielabokkie/laravel-apise)[ Packagist](https://packagist.org/packages/kielabokkie/laravel-apise)[ GitHub Sponsors](https://github.com/kielabokkie)[ RSS](/packages/kielabokkie-laravel-apise/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (7)Versions (35)Used By (0)

Apise for Laravel
=================

[](#apise-for-laravel)

[![Author](https://camo.githubusercontent.com/5660ca244b9dcf44b3d7795203c4cab7aaafa26dcc4499c8e347c1abd8b37942/687474703a2f2f696d672e736869656c64732e696f2f62616467652f666f6c6c6f772d406b69656c61626f6b6b69652d626c75652e7376673f6c6f676f3d74776974746572267374796c653d666c61742d737175617265)](https://twitter.com/kielabokkie)[![Build](https://camo.githubusercontent.com/1ccd433592a6c05f6ec8bc388dac5024c798ce4215a2640ee1609b227141d176/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b69656c61626f6b6b69652f6c61726176656c2d61706973652f72756e2d74657374732f6d61737465723f6c6f676f3d676974687562267374796c653d666c61742d737175617265)](https://github.com/kielabokkie/laravel-apise/actions)[![Packagist Version](https://camo.githubusercontent.com/3963bac9fe91994684699ab2db56907481964538fb3caf0347658acb50f8dfc6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b69656c61626f6b6b69652f6c61726176656c2d61706973652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kielabokkie/laravel-apise)[![Coverage](https://camo.githubusercontent.com/2fbac25532e5dc0c3ea4b5eeb8246fcfb3eb86dd18a34406e3ae43b147fa83cc/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f6b69656c61626f6b6b69652f6c61726176656c2d61706973653f7374796c653d666c61742d737175617265)](https://coveralls.io/github/kielabokkie/laravel-apise)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Apise for Laravel can be used to simplify creating an API service for integrating with an external JSON API. It also comes with an optional UI to view request and response data of your API services.

 [![screenshot](./art/screenshot1.png)](./art/screenshot1.png)

Requirements
------------

[](#requirements)

- PHP &gt;= 7.2
- Laravel 5.8 | 6 | 7 | 8

Note: Laravel 8 requires PHP 7.3

Installation
------------

[](#installation)

Install the package via composer:

```
composer require kielabokkie/laravel-apise
```

After the package is installed, you'll need to publish its assets:

```
php artisan apise:install
```

Run the migrations to setup the table used for logging:

```
php artisan migrate
```

### Updating Apise

[](#updating-apise)

When there is a new version of Apise always publish the assets with the command below to ensure you have the lastest Javascript and other assets.

```
php artisan vendor:publish --tag=apise-assets
```

Package configuration
---------------------

[](#package-configuration)

The configuration of the package can be found at `config/apise.php`. Below are the contents of the config file:

```
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'),
];
```

### Logging

[](#logging)

By default logging of all requests is enabled. This will give you a page under `/apise` where you can inspect request and response data. There will be some overhead when logging is enabled as records are saved to the database. To disable logging add the following to your `.env` file:

```
APISE_LOGGING_ENABLED=false

```

### Apise UI

[](#apise-ui)

As mentioned before the UI of Apise can be accessed via `/apise`. If you would like to change this you can do so by setting the following environment variable:

```
APISE_PATH='admin/apise'

```

### Conceal sensitive data

[](#conceal-sensitive-data)

You probably don't want sensitive data to be stored in your database so Apise will make it easy for us to conceal this kind of data. In the background Apise uses the [kielabokie/laravel-conceal](https://github.com/kielabokkie/laravel-conceal) package to automatically conceal sensitive headers and request data. By default the package conceals the values of `password` and `password_confirmation` fields but you can add any keys you want to the `conceal_keys` array in the `apise.php` config file:

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

Setup
-----

[](#setup)

To make use of the base API Client class you'll need to add the required `$baseUrl` to set the base URL of your API. You'll also have to call the `$this->setClient();` function in the constructor of your service class.

```
