Laravel-admin Explosive Reform (I)

Time:2019-9-20

Laravel-admin Explosive Reform (I)

Recently, we re-rounded the CMS with Laravel-admin, then changed it and recorded it. If you don’t think so, spray it below.

Laravel-admin Explosive Reform (I)

Laravel-admin is a tool that can help you build background management quickly. It provides functions such as page components and form elements. It can help you achieve a well-functioning background management function with very little code.

Installation:

composer require encore/laravel-admin

php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"

php artisan admin:install

Be careful:

When installing, data migration will be done. The first step is to check whether the data in your. env file is configured or not. Next, it should be noted that:

  • The configuration table prefix DB_PREFIX in Laravel 5.8. env file needs to modify the configuration file.
    Otherwise, you’ll look at its database.php configuration file just like me.

    ‘mysql’ => [

               'driver' => 'mysql',
               'url' => env('DATABASE_URL'),
               'host' => env('DB_HOST', '127.0.0.1'),
               'port' => env('DB_PORT', '3306'),
               'database' => env('DB_DATABASE', 'forge'),
               'username' => env('DB_USERNAME', 'forge'),
               'password' => env('DB_PASSWORD', ''),
               'unix_socket' => env('DB_SOCKET', ''),
               'charset' => 'utf8mb4',
               'collation' => 'utf8mb4_unicode_ci',
               'prefix' => '',
               'prefix_indexes' => true,
               'strict' => true,
               'engine' => null,
               'options' => extension_loaded('pdo_mysql') ? array_filter([
                   PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
               ]) : [],
           ],
    

In the long run, you will find that prefix is nowInstead of‘prefix’ => env(‘DB_PREFIX’, ”),

  • Errors may occur during data migration:

    1 PDOException::(“SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes”)

         D:\phpStudy\WWW\Laravel-study\Laravel-Study\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
    

    2 PDOStatement::execute()

         D:\phpStudy\WWW\Laravel-study\Laravel-Study\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
    

The reason for this error is explained a lot on the internet. Instead of repeating it here, modify the AppServiceProvider.php file directly:

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

Modification completed, data migration completed, the above three commands completed, look at the directory structure:

After installation, the background installation directory is app / Admin, and most of the background development coding work is done in this directory.

    app/Admin
    ├── Controllers
    │   ├── ExampleController.php
    │   └── HomeController.php
    ├── bootstrap.php
    └── routes.php

As you can see, here the Admin directory is under the app directory, not under the HTTP directory we used to make.


Visit

Direct access after installation

http://localhost/laravel-admin/admin/

The effect is as follows:

Laravel-admin Explosive Reform (I)

English, for people like me who are not so good at English, we still have to sinicize it.

App.php modification in config directory

'locale'=>'zh-CN', //en to zh-CN

It’s sinicized, and then it logs in: usernameadminPasswordadmin

Here you can see that PFinal-cms is my landing title. This modification is as follows:

Because laravel-admin generates the configuration background configuration file admin.php in the process of installation, just modify admin.php:

Amend as follows:

return [

    /*
    |--------------------------------------------------------------------------
    | Laravel-admin name
    |--------------------------------------------------------------------------
    |
    | This value is the name of laravel-admin, This setting is displayed on the
    | login page.
    |
    */
    'name' => 'PFinal-cms',

    /*
    |--------------------------------------------------------------------------
    | Laravel-admin logo
    |--------------------------------------------------------------------------
    |
    | The logo of all admin pages. You can also set it as an image by using a
    | `img` tag, eg '<img>'.
    |
    */
    'logo' => '<b>PFinal</b> admin',

    /*

The effect of the modification is as follows:

Laravel-admin Explosive Reform (I)

The effect after landing is as follows:

Laravel-admin Explosive Reform (I)

Other modifications and pit filling, please pay attention to the column, we will continue in the next article.

For more knowledge sharing, please pay close attention to:

Laravel-admin Explosive Reform (I)

Recommended Today

Install SQL Server tutorial under Ubuntu

Microsoft has just announced a public preview of the next generation of SQL Server, and Canonical has officially announced that this preview version is available for Ubuntu. Whether deployed in-house or in the cloud, SQL Server on Ubuntu offers developers and organizations more freedom of choice. The development languages and data types allowed by SQL […]