# Installation

# System requirements

  • Laravel >= 8
  • PHP >= 7.3

# Install with composer

Either install from the command line:

composer require "lanternphp/lantern"

Or by add the following to your composer.json file:

{
    "require": {
        "lanternphp/lantern": "~1.0"
    }
}

And run:

composer update lanternphp/lantern

# Set up

The starting point is the base feature group that will declare all other features and actions.

It can be named anything you want, but we'll call this AppFeatures (in src/AppFeatures.php).

<?php 

use Lantern\Features\Feature;

class AppFeatures extends Feature
{
    const DESCRIPTION = 'Top-level feature';

    const FEATURES = [
        /* features will go in here */
    ];
}

This top-level Feature group will need to be declared to Lantern from AppServiceProvider within the boot method.

Lantern is configured by calling static methods on the Lantern\Lantern class. We use the setUp() method to declare the base feature group.

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Lantern\Lantern;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        $this->setupLantern();
    }
    
    protected function setupLantern()
    {
        Lantern::setUp(AppFeatures::class);
    }
}

# Directory path

By default, when Lantern searches for a binary on the command line, it will take either:

  1. Your open_basedir (opens new window) path if set, otherwise
  2. The paths present in your $PATH environment variable

… and combine these paths with:

[
    base_path(), // the folder into which Laravel is installed
    base_path('vendor/bin'), // where composer's binaries are stored 
]

See the Laravel documentation (opens new window) for more information on the base_path() method.

If your system requires a executable outside these directories, then you will need to provide this location to Lantern in order to use that binary as a constraint. You can do this via the pathDirs method, which you should call before the setup method in AppServiceProvider.


<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Lantern\Lantern;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        $this->setupLantern();
    }
    
    protected function setupLantern()
    {
        Lantern::pathDirs([
            '/usr/local/bin/',
            '/var/www/bin',
        ]);
        
        Lantern::setUp(App\Features::class);
    }
}

Open Base Directory

NB: if you have configured open_basedir (opens new window), then you cannot search directories outside of this path.