magiclabs/magic-laravel

Magic Admin Laravel Library

v0.1.6 2023-02-28 20:31 UTC

This package is auto-updated.

Last update: 2024-04-28 23:05:37 UTC


README

This package provides direct Laravel integration for Magic Admin PHP SDK.

Requirements

Laravel 5.3 or newer.

Installation

Run this command to install via composer.

composer require magiclabs/magic-laravel

Older Laravel Installations

If you are using Laravel 5.5 or newer then skip this part. Otherwise you will need to manually register the service provider and facade alias by going to config/app.php.

Add to the providers array:

MagicLaravel\ServiceProvider::class

Add to the aliases array:

'Magic' => MagicLaravel\Facade::class,

Setup

Publish config file.

php artisan vendor:publish --provider="MagicLaravel\ServiceProvider"

Add MAGIC_SECRET_API_KEY to your .env file by going to the Magic Dashboard.

MAGIC_SECRET_API_KEY=sk_XXXX_XXXXXXXXXXXXXXXX

Usage

For complete documentation see Magic Admin PHP SDK and the Magic docs.

Get instance using the app helper:

$magic = app('MagicLaravel\Magic');

$magic->token->validate('<DID_Token>');

$magic->user->get_metadata_by_token('<DID_Token>');

Or get instance using the facade:

use Magic;

Magic::token()->validate('<DID_Token>');

Magic::user()->get_metadata_by_token('<DID_Token>');