Installation

Laravel

In order to start building your project with GreenLight, you need a working Laravel 5.7+ instance. Regarding the installation procedure of Laravel you can find information in the official documentation site of the framework.

Make sure you have all environment and config values set correctly to proceed further to the package installation. Also, in order to avoid migration conflicts, make sure you either skip running the migrations of your fresh Laravel install, or use your own, customized migrations derived from GreenLight.

GreenLight

1. Composer install

Since GreenLight is a private package only published to GitHub, you need minor adjustments to your composer.json file to make sure you can add it to your project.

Adding the GreenLight repository to your composer repository definitions:

"repositories": [
     {
         "type": "vcs",
         "url": "https://github.com/greenroomgit/greenlight.git"
     }
 ],

Loading the package via composer:

composer require greenroom/greenlight

2. Service providers

After installing GreenLight, you need to register the service providers of the package in your config/app.php file. Add the following to the providers config section:

Dimsav\Translatable\TranslatableServiceProvider::class, // 3rd party package, translations provider
Greenroom\GreenLight\GreenLightServiceProvider::class // GreenLight

Also consider registering the providers of the Laravel Migrations Generator and Reliese Laravel packages if you need code generation functions later (if you have just started your project and plan to use GreenLight to its full potential, you will need them).

Check your Laravel application out:

php artisan serve

If the package installation was successful, visiting http://localhost:8000/admin should show the default admin login page. However, there are a few more tasks to do before you can start using GreenLight.

3. Migrations

In case you are planning to build your project entirely using GreenLight, it is recommended to remove the default migration files of Laravel (database/migrations) to avoid conflicts!

Most likely you will need the admin interface functions of GreenLight in your project, which requires you to run the migrations included in the package file. By default the package already loads all migration files while running your Laravel instance, all you have to do is run the migration command as you would do in any Laravel project:

php artisan migrate

Also, it is recommended to run the GreenLight database seeder, so you would not have to worry about generating initial records for your system:

php artisan db:seed --class=Greenroom\GreenLight\Database\Seeds\DatabaseSeeder

4. Publishing resources of the package

Your installation process is almost finished. However, before you can start using certain elements of GreenLight (ie. the admin interface or the frontend developer boilerplate), you will need to run the following commands to publish the frontend resources used by the package.

Core elements:

php artisan vendor:publish --tag=greenlight-core

Frontend development boilerplate (optional):

php artisan vendor:publish --tag=greenlight-frontend

5. Recommended changes in your Laravel app

  1. Make sure locales (both default and fallback) and timezone are set correctly in config/app.php
  2. Publish the config file of the translations package (dimsav/translatable): php artisan vendor:publish --tag=translatable.
  3. Set available locales (has to be a one-dimensional array) and fallback options in config/translatable.php
  4. Set the following parameters in .env (soon to be moved to a separate GreenLight config file):
    • SITE=NAME_OF_SITE
    • LOCALE_HU=hu
    • LOCALE_EN=en
    • any other LOCALE_## parameter, given value should be the name of the corresponding locale handled by PHP
  5. Publish the config file of the permission handler package (santigarcor/laratrust): php artisan vendor:publish --tag=laratrust.
  6. Configure Laratrust in config/laratrust.php. Even though the GreenLight ACL system is currently being reworked, it is recommended to either use the models it provides for Laratrust, or publish your own user handler models from Laratrust. Docs: http://laratrust.readthedocs.io/en/5.0/index.html.

    Having Laratrust configured is optional yet, but it is expected to be mandatory soon as the GreenLight admin middleware is going to be replaced with Laratrust solutions.