This document describes how to configure background logon in PHP and how to introduce a template. It has good reference value. let's take a look at it below (1) under the project. env is the file for configuring the database.
DB_HOST=127.0.0.1DB_DATABASE=blogDB_PREFIX=blog_DB_USERNAME=rootDB_PASSWORD=123.comg
Write the database server address, connected database name, table prefix, user name, and password respectively.
The table prefix DB_PREFIX field does not exist by default. you need to add
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => env('DB_PREFIX', ''), 'strict' => false, 'engine' => null, ],
(2) Check whether the verification is successful
Create a controller
Php artisan make: controller IndexController
getPdo(); dd($pdo); }}
Add route information:
Route: get ('/test', 'indexcontroller @ index ');
Verification result:
(3) import the prepared template
Rename server. php to index. php, and move public/. htaccess to the project directory. it is in the same directory as index. php. // at this time, it can be accessed in the form of 127.0.0.1 without public access.
Add the template admin to the views directory.
Add route:
Route: get ('/admin/login', 'admin \ LoginController @ login ');
Modify the controller LoginController. php
public function login() { return view('admin.login');}
Change views/admin/login.html to login. blade. php.
During access, pay attention to whether the css file is loaded
Result:
Note: The background template and the xampp installation package are in the following link:
Http://pan.baidu.com/s/1hs5Jass
The above is all the content of this article. I hope this article will help you in your study or work, and I also hope to support PHP!
For more articles about PHP configuration background logon and template introduction, refer to PHP Chinese network!