Laravel 学习一:安装

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/

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值