安装
Requirements
- PHP >=
7.1 - Laravel
5.5.0~8.* - Fileinfo PHP Extension
Start installing
{tip} If
composerdownloads too slowly or fails to install during installation Please run the commandcomposer config -g repo.packagist composer https://mirrors.aliyun.com/composer/to replace thecomposerpackagist server with the Aliyun mirror.
First you need to install laravel, if you already have it installed you can skip this step.
composer create-project --prefer-dist laravel/laravel ProjectName 7.*
# 或
composer create-project --prefer-dist laravel/laravel ProjectName
After installing laravel, you will need to modify the .env file to set the database connection to the correct settings.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=dcat-admin
DB_USERNAME=root
DB_PASSWORD=
Installation of dcat-admin
cd {ProjectName}
composer require dcat/laravel-admin:"2.*" -vvv
Then run the following command to publish the resource:
php artisan admin:publish
The command will generate the configuration file config/admin.php, in which you can modify the installation address, database connection, and table name, it is recommended that all the default configuration is not modified.
Then run the following command to complete the installation:
{tip} Executing this command may result in the following error
Specified key was too long ... 767 bytesIf this error occurs, add the code\Schema::defaultStringLength(191);to thebootmethod of theapp/Providers/AppServiceProvider.phpfile. Then delete all the data tables in the database and run thephp artisan admin:installcommand again.
php artisan admin:install
After the above steps are completed, you can configure the webserver, Note that you need to point the document root to the public directory! If you are using nginx, you also need to add a pseudo-static configuration to the configuration:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
After starting the service, open http://localhost/admin in your browser and log in with the username admin and password admin.
Generated documents
After installation, the following file is generated in the project directory:
Configuration file
After the installation is complete, all the configuration for dcat-admin is in the config/admin.php file.
Back-end project document
After the installation is complete, the backend installation directory is app/Admin, after which most of the backend development coding work is done in this directory.
app/Admin
├── Controllers
│ ├── ExampleController.php
│ └── HomeController.php
├── Metrics
│ └── Examples
│ ├── NewDevices.php
│ ├── NewUsers.php
│ ├── ProductOrders.php
│ ├── Sessions.php
│ ├── Tickets.php
│ └── TotalUsers.php
├── bootstrap.php
└── routes.php
app/Admin/routes.phpfile is used to configure background routing.app/Admin/bootstrap.phpIt is the startup file ofdcat-admin, please refer to the comments in the file for how to use it.app/Admin/Controllersdirectory is used to store the background controller file, theHomeController.phpfile in this directory is the display controller of the background home page,ExampleController.phpis an example file.app/Admin/Metrics/Examplescontains thestatistics card (Metric Card)sample code.
Static files
The front-end static files needed for the backend are in the /public/vendor/dcat-admin directory.
Data table migration file
The corresponding data table migration file is in the /database/migrations directory.
Language packs
The language package files are located in the directory /resources/lang.