Laravel

Our Laravel package allows you to access secrets managed by Manifold directly from within your Laravel code. This allows you to avoid hard-coding secrets and configuration variables into your env config files.

Installation

  1. Install the package
composer require manifoldco/manifold-laravel
  1. Publish the config file and select manifoldco\manifold-laravel from the vendor list
php artisan vendor:publish

Configuration

Create an API key

An API key is required for your user or team, so that we can securely look up and decrypt credentials in Laravel. API keys are currently created through the Manifold CLI. For the Laravel package you must grant read-credentials access to the token.

To get started with API tokens refer to the authentication documentation.

Providing an API Key to Laravel

Add MANIFOLD_API_TOKEN=your-token-here to your .env file

Options

You can also set your specific Manifold project via MANIFOLD_PROJECT=your-project-label

Usage

Once installed and configured, your project/resource credentials from Manifold will be pulled into your Laravel application as configurations. Your credentials can be accessed using the confighelper, using the label of the resource and the key of credential, as they exist in Manifold, using dot-notation. For example, if you have a Mailgun resource setup with a credential named API_KEY, it can be accessed using config("mailgun.API_KEY") (where mailgun is the resource's label).

Note that keys are case sensitive. Also note that when configurations conflict with other Laravel configs, the Manifold configurations will take priority.

Example

You have a project in Manifold with a label of my-project. You want your Mailgun API key available in a controller method. Your Mailgun resource is named mailgun and the API key credential is API_KEY.

Add the following to .env

MANIFOLD_API_TOKEN=your-token
MANIFOLD_PROJECT=my-project

In your controller's php file:

class MyController extends Controller{
    public function process_mail(){

        $mailgun_key = config('mailgun.API_KEY');

        //mail processing logic here
    }
}

More examples are shown in the repo and in our example project here