PHP configuration background login and template introduction, php background template Introduction
(1) 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
<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;use App\Http\Requests;use Illuminate\Support\Facades\DB;class IndexController extends Controller{ public function index() { $pdo = DB::connection()->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
<link rel="stylesheet" href="{{asset('resources/views/admin/style/css/ch-ui.admin.css')}}"><link rel="stylesheet" href="{{ asset('resources/views/admin/style/font/css/font-awesome.min.css')}}">
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. I also hope to provide more support to the customer's home!