1、浏览官方文档
https://www.golaravel.com/
2、根据文档安装laravel
https://docs.golaravel.com/docs/5.6/installation/
按照文档创建项目 blog
3、了解artisan
https://laravel.com/docs/5.0/artisan
https://www.golaravel.com/post/laravel-5-0-artisan-cli-options-list/
4、使用artisan创建第一个控制器,视图
创建控制器:
php artisan make:controller HelloController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HelloController extends Controller
{
//
public function index(){
return view('hello.index');
}
}
创建视图:
在目录app/resources/views/下创建文件夹hello,创建文件index.blade.php
<!doctype html>
<html>
<h1>Hello Mike</h1>
</html>
5、添加路由:
在routes/web.php中添加路由
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/hello/','HelloController@index');
6、运行项目
php artisan serve
访问:http://127.0.0.1:8000/hello/