liran-co/laravel-frontend-services

Easily add third-party services to your front-end.

v0.1 2021-04-16 23:00 UTC

This package is auto-updated.

Last update: 2024-11-17 06:57:35 UTC


README

⚠️ Warning: This is a pre-release version that is not yet ready for production use.

Laravel Frontend Services exposes Blade Components that make it easier to integrate and include the scripts of third-party services.

Latest Stable Version Total Downloads License

Installation

To get started, install the liran-co/laravel-frontend-services package:

composer require liran-co/laravel-frontend-services

Usage

First, add the relevant configuration values for each service you'd like to use in the config/services.php file.

<?php

return [

    // ...

    'intercom' => [
        'app_id' => env('INTERCOM_APP_ID'),
    ],

    // ...

];

You'll find a full list of supported services below with their corresponding configuration keys.

Next, use Blade component syntax to include the service in your view:

<x-services::intercom />

Typically you'll want to either do this in the <head> section of your site or before the closing </body> tag.

Advanced Usage

Show

If you'd like to include a service based on some conditional, you can use the show attribute on the component. For example, to only include the Intercom service when a user is logged in, you can do this:

<x-services::intercom show={Auth::check()} />

Environments

Since it's common to only include certain scripts in production environments, you can define an environments key in your config file that will automatically cause the service to be included if the current environment matches one in the array:

'intercom' => [
    'app_id' => env('INTERCOM_APP_ID'),
    'environments' => ['production', 'staging'],
],

Supported Services

License

Released under the MIT license. See LICENSE for more information.