Giter VIP home page Giter VIP logo

laravel_8_boilerplate's Introduction

Laravel / AdminLTE 3 Boilerplate

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

This package serves as a basis for quickly creating a back-office. It includes profile creation and his management, user management, roles, permissions and log viewing.

It also makes it easy to add other packages to extend the features, have a look to sebastienheyd/boilerplate-packager to quickly build your own package for boilerplate.

Other packages to extend the features :

Full documentation

The full documentation is readable on Github pages

Features

Installation

  1. In order to install Laravel/AdminLTE Boilerplate run :
composer require sebastienheyd/boilerplate
  1. Run the command below to publish assets, lang and configuration files
php artisan vendor:publish --tag=boilerplate
  1. After you set your database parameters 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 : url admin prefix, backend locale, redirection after login (see comments in file), ...
  • 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 to use and menu classes
  • theme.php : backend theme configuration

Dashboard

You can override the dashboard view by publishing it :

php artisan vendor:publish --tag=boilerplate-dashboard

After that, you will find the view dashboard.blade.php in resources/views/vendor/boilerplate

If you need to have a controller for more flexibility, you can run the following artisan command :

php artisan boilerplate:dashboard

This will publish for you the view, the DashboardController.php file in the app/Http/Controllers/Boilerplate folder and modify the configuration file config/boilerplate/menu.php.

You can also use your own dashboard controller by changing the dashboard value 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 boot()
{
    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, Font Awesome and AdminLTE scripts and styles are loaded.

To load and use plugins like Datatables, Date Picker, TinyMCE, ... 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 Tempus Dominus / Date Range Picker Example
boilerplate::load.select2 Select2 Example 
boilerplate::load.fileinput Bootstrap FileInput Example
boilerplate::load.fullcalendar FullCalendar Example
boilerplate::load.moment MomentJs  

Some plugins are loaded by default :

You can see examples on the default dashboard.

Language

The default language used by boilerplate is the global application language set as locale in config/app.php.

You can define another default language for the admin panel by setting the default parameter in config/boilerplate/locale.php.

You can activate a language switch by setting to true the switch parameter in config/boilerplate/locale.php. A language selector will so be shown on the login page and in the top bar. Select allowed switchable languages by setting the allowed parameter in config/boilerplate/locale.php

See the full documentation

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

Views

You can override views by running php artisan vendor:publish --tag=boilerplate-views. You will then find the views in the resources/views/vendor/boilerplate folder.

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 --tag=boilerplate-public --force

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

{
    "scripts": {
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=boilerplate-public --force -q"
        ]
    }
}

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);
}

Contributing

Please see contributing.md for details and a todolist.

Credits

License

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

Special thanks

This project is made with PhpStorm and supported by JetBrains

JetBrains Logo

laravel_8_boilerplate's People

Contributors

sebastienheyd avatar aliqasemzadeh avatar ruospo avatar dylan-dpc avatar scrutinizer-auto-fixer avatar mavisland avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.