Skip to content
Laravel AdminLTE Boilerplate package with user, roles and permissions management
PHP HTML JavaScript Other
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src TinyMCE code edit indent & line wrap Dec 3, 2019
tests Apply fixes from StyleCI Mar 23, 2019
.gitattributes Ignore public folder for Github Mar 10, 2019
.gitignore Resources Dec 2, 2019
.travis.yml Update .travis.yml Mar 23, 2019
LICENSE.md License and readme Apr 1, 2017
Makefile PSR2 / PHP_CodeSniffer / PHPUnit & tests Mar 7, 2019
README.md
_config.yml Set theme jekyll-theme-cayman Apr 8, 2019
composer.json TinyMCE code_change_callback function Nov 26, 2019
phpcs.xml Menu items repository / Readme Nov 26, 2019
phpunit.xml Functional tests with Laravel Dusk Mar 8, 2019

README.md

Laravel/AdminLTE Boilerplate

Package Build Status StyleCI Scrutinizer Code Quality Laravel Nb downloads MIT License

This package is to be served as a basis for a web application. It allows you to access to an administration panel to manage users, roles and permissions.

For older Laravel versions : 5.8 / 5.7 / 5.6 / 5.5 / 5.4

Features

Installation

  1. In order to install Laravel/AdminLTE Boilerplate run :
composer require sebastienheyd/boilerplate
  1. Run the command below to publish assets, views, lang files, ...
php artisan vendor:publish --provider="Sebastienheyd\Boilerplate\BoilerplateServiceProvider"
  1. After you set your database parameters in your .env file run :
php artisan migrate

Optional

If you want to quickly test your Laravel application.

php artisan serve

Now you can point your browser to http://localhost:8000/admin

Configuration

Configuration files can be found in config/boilerplate folder.

  • app.php : name of the application (only backend), admin panel prefix, redirection after login (see comments in file), AdminLTE skin and more...
  • auth.php : overriding of config/auth.php to use boilerplate models instead of default Laravel models. Allow you to define if users can register from login page and which role will be assigned to a new user.
  • laratrust.php : overriding of Laratrust (package santigarcor/laratrust) default config.
  • menu.php : dashboard and menu classes

Dashboard

You can define your own controller to display the dashboard by setting the dashboard parameter in config/boilerplate/menu.php.

Adding items to the menu

To add an item to the menu, nothing simpler, use the artisan boilerplate:menuitem command provided with boilerplate.

This command will generate the classes needed to generate the menu item in the app/Menu folder.

php artisan boilerplate:menuitem {name} {-s} {-o=100}
option / argument description
name Class name to generate
-s --submenu Menu item must have sub item(s)
-o --order Menu item order in the backend menu

Once generated, the files can be edited to customize the item.

You can also add your own providers by adding their classnames to the array of providers in the configuration file config/boilerplate/menu.php. This can be useful if you don't want to use the default directory app/Menu in your application.

For package developers, menu items providers can be added by using the boilerplate.menu.items singleton in your package service provider. Example :

public function register()
{
    app('boilerplate.menu.items')->registerMenuItem([
        Users::class,
        Logs::class,
    ]);
}

For more information, see the documentation of the following packages:

Loading plugins assets

By default, only jQuery, bootstrap 3, Font Awesome and AdminLTE scripts and css are loaded.

To load and use plugins like datatables, datepicker, icheck, ... you can use "loaders". These are blade templates prepared to add the loading of scripts and styles for a plugin.

For example, you want to use a datepicker on a text field :

@include('boilerplate::load.datepicker')

@push('js')
    <script>
        $('.datepicker').datepicker();
    </script>
@endpush

Here @include('boilerplate::load.datepicker') will load scripts and styles to allow usage of datepicker. After that you can push your scripts on the js stack (or styles on the css stack).

Available loaders are :

Loader Documentation
boilerplate::load.tinymce TinyMCE Example
boilerplate::load.codemirror CodeMirror Example 
boilerplate::load.datatables Datatables Example
boilerplate::load.datepicker DatePicker / DateTimePicker / DateRangePicker Example
 boilerplate::load.icheck iCheck Example 
boilerplate::load.select2 Select2 Example 
boilerplate::load.moment MomentJs  
boilerplate::load.fileinput Bootstrap FileInput  

More will come...

Some plugins are loaded by default :

You can see examples on the default dashboard.

Language

By default the language used by boilerplate is the application language declared into config/app.php (locale). You can define another language only for the back-office by setting locale parameter in config/boilerplate/app.php.
Supported language are English, French, Spanish and Turkish.

When you run php artisan vendor:publish --provider="Sebastienheyd\Boilerplate\BoilerplateServiceProvider", only the language files for form validation are copied for supported languages. Thanks to caouecs/Laravel-lang package !

You can translate into a language not yet supported by copying the src/resources/lang/boilerplate folder content into resources/lang/vendor/boilerplate folder. After that, copy or rename one of the language folders in the new language folder to create. All you have to do is translate. If you want to share the language you have added, don't hesitate to make a pull request.

Routes

Routes are loaded from the file boilerplate.php.

A default prefix admin is set into the config file app.php, this is why boilerplate is accessible by /admin url. You can set an empty prefix if you remove the default route / defined in routes/web.php

Package update

Boilerplate comes with assets such as Javascript, CSS, and images. Since you typically will need to overwrite the assets every time the package is updated, you may use the --force flag :

php artisan vendor:publish --provider="Sebastienheyd\Boilerplate\BoilerplateServiceProvider" --tag=public --force

To auto update assets each time package is updated, you can add this command to post-autoload-dump into the file composer.json at the root of your project.

{
    "scripts": {
        "post-autoload-dump": [
            "@php artisan vendor:publish --provider=\"Sebastienheyd\\Boilerplate\\BoilerplateServiceProvider\" --tag=public --force -q",
        ]
    }
}

If needed, you can force update for these tags : config, lang, public

tag description destination path
config Configuration files app/config/boilerplate
lang Laravel default lang files for form validation ressources/lang
public Public assets, you must update it after each package update public/assets/vendor/boilerplate

Tests / Coding standards

This package is delivered with a Makefile used to launch checks for the respect of coding standards and the unit tests

Just call make to see the list of commands.

Laravel Dusk functionnal tests

This package is also delivered with functional tests using Laravel Dusk

After installing Laravel, Laravel Dusk and configuring your database, you can start the tests with the following command :

php artisan dusk vendor/sebastienheyd/boilerplate/tests/DuskTest.php

Important : Never launch tests with Laravel Dusk if you have data in your database, Dusk will wipeout all your datas

Troubleshooting

Dates localization

Since Laravel 5.8, this package use Carbon 2 instead of Jenssegers/Date to translate dates.

Date format now use the format of momentjs. To translate your dates, you must now use the Carbon 2 class method isoFormat instead of format

See Carbon 2 documentation

Migration error

MySQL < v5.7.7 or MariaDB

When you run php artisan migrate and you hit this error :

[PDOException]
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

This is an error from a change since Laravel 5.4 : see here

To correct this, two possibilities :

  • Define utf8 instead of utf8mb4 as default database charset and utf8_unicode_ci instead of utf8mb4_unicode_ci as default database collation.

  • Edit your app/Providers/AppServiceProvider.php file and define a default string inside the boot method :

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

License

This package is free software distributed under the terms of the MIT license.

You can’t perform that action at this time.