laravel5.5初探

2018-02-11 14:10:27来源:oschina作者:BeanHo人点击

分享

1.新建项目


$ valet restart
$ cd ~/Sites
$ laravel new sample

访问http://sample.test/


2.Git一下


$ cd ~/Sites/sample
$ git init
$ git add . && git commit -m "Initial commit"

在 Coding上新建一个名为sample的项目


$ git remote add origin git@git.coding.net:beanho/laravel-sample.git
$ git pull origin master --allow-unrelated-histories
$ git push -u origin master

3.构建页面


3.1 新建分支


$ git checkout master
$ git checkout -b static-pages

3.2 移除无用视图


$ rm resources/views/welcome.blade.php

3.3配置路由


routes/web.php


<?php
Route::get('/', 'StaticPagesController@home');
Route::get('/help', 'StaticPagesController@help');
Route::get('/about', 'StaticPagesController@about');

3.4生成静态页面控制器


$ php artisan make:controller StaticPagesController
<?php
namespace App/Http/Controllers;
class StaticPagesController extends Controller
{
public function home()
{
return view('static_pages/home');
}
public function help()
{
return view('static_pages/help');
}
public function about()
{
return view('static_pages/about');
}
}

3.5添加静态页面视图


$ mkdir resources/views/static_pages
$ touch resources/views/static_pages/home.blade.php
$ touch resources/views/static_pages/help.blade.php
$ touch resources/views/static_pages/about.blade.php

3.6使用通用视图


$ mkdir resources/views/layouts
$ touch resources/views/layouts/default.blade.php

resources/views/layouts/default.blade.php





Sample App


@yield('content')


resources/views/static_pages/home.blade.php


@extends('layouts.default')
@section('content')

主页


@stop

resources/views/static_pages/help.blade.php


@extends('layouts.default')
@section('content')

帮助页


@stop

resources/views/static_pages/about.blade.php


@extends('layouts.default')
@section('content')

关于页


@stop

4.优化页面


5.用户模型


6.用户注册


7.会话管理


8.用户CURD


9.邮件发送


10.微博CURD


11.粉丝关系


最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台