作者: 何朱必 分类: 开发笔记 发布时间: 2018-03-16 21:58 ė views 6 28条评论



从“路由”开始,玩一把“Hellow world!”

Route::get(‘/’, function () {

//return view(‘welcome’);

return ‘Hellow world!’;


laravel 的每一个路由是需要手动定义的,默认欢迎页面(参数)

是 resources/views 目录下的文件名welcome.blade.php去掉 blade.php后缀,对应的路由

url 是 http://www.rk.com/


Route::get(‘tests’, function () {

return view(‘logo’);



是 resources/views 目录下的文件名logo.blade.php去掉 blade.php后缀


url 就应该是 http://www.rk.com/tests


路由中还可以引入 html 页面,可以在 route/web.php 中搞定一切。

先前,我们已经在PhpStorm中安装了昵称为artisan 的 laravel 命令行接口,也就是根目录下的 artisan 文件,用法是输入命令:

Php artisan

意思就是使用 php 的命令行模式运行 artisan.php 文件,php命令行下是可以不需要文件后缀就能识别的,所以根目录下的 artisan 文件并没有带上 .php


php artisan.php 命令行主要有两个作用:


Php artisan make:controller ArticleController

结果是生成了一个 app/Http/Controllers/ArticleController.php 文件;

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ArticleController extends Controller






Php artisan make:controller ArticleController--resource

不但增、删、改、查的方法都定义好了,连注释都给写好了。这其实是按 RESTful 规范生成的格式,除了 GET POST 它还包含了一大堆请求方式:
也就是说 Route:: 后面还可以跟上面这些方法。


public function index() {

return view(‘admin/index’);


路由(R)-控制器(C)用起来也非常简单,直接写控制器名在路由(R)闭包函数的这个位置即可,然后用 @ 符号分割控制器和控制器的方法(可以是形参或闭包函数),例如:

Route::get(‘article/index’, ‘ArticleController@index’)

Route::post(‘article/store’, ‘ArticleController@store’)



本文永久链接: http://www.hezhubi.com/larave2.htm



  1. Deon 2019年7月23日 上午6:55

    Oh my goodness! Impressive article dude! Thank you so much, However I am having problems with
    your RSS. I don’t understand why I cannot subscribe to it.
    Is there anybody getting identical RSS issues?
    Anyone who knows the answer can you kindly respond? Thanx!!

  2. Victor 2019年7月23日 上午6:45

    I’ve been browsing online greater than three hours lately,
    but I never found any interesting article like yours.
    It is beautiful price enough for me. Personally,
    if all site owners and bloggers made good content material as you did, the web will be a lot more useful than ever

  3. Grady 2019年7月22日 上午11:46

    Magnificent goods from you, man. I’ve understand your stuff previous to and you
    are just too magnificent. I actually like what you’ve acquired here, really like what you are stating and the way in which you say it.
    You make it enjoyable and you still take care of to keep it
    sensible. I can’t wait to read much more from you. This is really a terrific website.

  4. Louie 2019年7月22日 上午2:22

    If some one desires to be updated with hottest technologies therefore he must be visit this
    site and be up to date every day.

  5. Adele 2019年7月21日 上午2:29

    Hello There. I found your blog using msn. This is
    a very well written article. I’ll make sure to bookmark it and come back to read more of your useful information. Thanks for
    the post. I will certainly return.

  6. Margot 2019年7月21日 上午12:49

    Pretty! This has been an incredibly wonderful post. Many thanks for
    supplying these details.

  7. Rebekah 2019年7月20日 下午10:22

    This is really interesting, You are a very skilled blogger.

    I’ve joined your feed and look forward to seeking more of your wonderful post.
    Also, I have shared your web site in my social networks!

  8. Roxanne 2019年7月20日 下午2:29

    Wow, that’s what I was searching for, what a stuff!

    present here at this webpage, thanks admin of this web page.

  9. Dawn 2019年7月19日 下午9:57

    I think the admin of this website is actually working hard in support of his site,
    since here every information is quality based information.

  10. Leigh 2019年7月19日 下午8:13

    Hey there! This is kind of off topic but I need
    some help from an established blog. Is it difficult to
    set up your own blog? I’m not very techincal but I can figure things out
    pretty quick. I’m thinking about making my own but I’m not sure
    where to start. Do you have any tips or suggestions?
    With thanks

  11. Hortense 2019年7月19日 上午5:32

    Hey! I just wanted to ask if you ever have any problems with
    hackers? My last blog (wordpress) was hacked and
    I ended up losing months of hard work due to no data backup.
    Do you have any solutions to prevent hackers?

  12. Sunny 2019年7月18日 上午9:35

    I think everything said made a ton of sense.
    However, what about this? suppose you wrote a catchier title?
    I am not suggesting your content isn’t good., however suppose you added something that grabbed a person’s
    attention? I mean 手把手教你跑Larave框架实战笔记系列之二 is a little plain.
    You could look at Yahoo’s home page and see how they write news titles to grab people
    to click. You might add a video or a pic or two to grab people interested about everything’ve got to say.
    In my opinion, it could make your posts a little livelier.

  13. Chastity 2019年7月16日 下午10:58

    you are in point of fact a good webmaster. The site loading speed is amazing.
    It sort of feels that you’re doing any unique trick.
    In addition, The contents are masterwork. you have performed a wonderful process on this matter!

  14. Clement 2019年7月16日 下午2:11

    Greetings from Ohio! I’m bored to tears at work so I decided to
    check out your blog on my iphone during lunch break. I enjoy the info you provide
    here and can’t wait to take a look when I get home.
    I’m shocked at how quick your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyhow, excellent blog!

  15. Dallas 2019年7月16日 上午3:20

    Now I am ready to do my breakfast, afterward having my breakfast coming again to read additional news.

  16. Edith 2019年7月13日 下午1:34

    Great site. A lot of useful information here. I am sending it to several friends ans additionally sharing in delicious.
    And obviously, thanks to your sweat!

  17. Alisia 2019年7月13日 上午3:39

    Excellent, what a blog it is! This webpage provides helpful information to us, keep it up.

  18. Teresa 2019年7月13日 上午2:29

    I’m amazed, I have to admit. Seldom do I encounter a blog that’s both
    equally educative and entertaining, and without a doubt, you’ve hit
    the nail on the head. The issue is something which not enough folks are speaking
    intelligently about. Now i’m very happy that I stumbled across this during my search for
    something relating to this.

  19. Reina 2019年7月12日 下午7:13

    I need to to thank you for this wonderful read!!

    I definitely loved every bit of it. I’ve got you book marked to look at
    new stuff you post…

  20. Lela 2019年7月12日 下午12:12

    Heya i am for the first time here. I found this board and I to
    find It truly useful & it helped me out a lot.
    I hope to offer something back and aid others like you helped me.

  21. Rufus 2019年7月12日 上午5:12

    This design is incredible! You certainly know how to keep a reader entertained.
    Between your wit and your videos, I was almost moved to start my own blog
    (well, almost…HaHa!) Wonderful job. I really loved what you had to say,
    and more than that, how you presented it. Too

  22. Eartha 2019年7月12日 上午1:14

    Useful info. Lucky me I found your site by chance,
    and I am stunned why this coincidence didn’t came about in advance!

    I bookmarked it.

  23. Carroll 2019年7月11日 下午12:50

    It’s a pity you don’t have a donate button! I’d without a doubt donate to this brilliant
    blog! I guess for now i’ll settle for bookmarking and adding your RSS feed
    to my Google account. I look forward to brand new updates and will talk about
    this blog with my Facebook group. Talk soon!

  24. Stewart 2019年7月11日 上午8:46

    Heya i am for the first time here. I came across this board
    and I find It truly useful & it helped me out
    a lot. I hope to give something back and help
    others like you helped me.

  25. Elvin 2019年7月11日 上午4:01

    I’m extremely inspired with your writing talents as neatly as with the structure on your weblog.
    Is this a paid theme or did you customize it yourself?

    Anyway stay up the excellent high quality writing,
    it is uncommon to look a nice weblog like this one these days..

  26. Alva 2019年7月11日 上午2:33

    Excellent article. Keep writing such kind of information on your page.
    Im really impressed by your site.
    Hi there, You have done a great job. I’ll definitely
    digg it and for my part recommend to my friends.

    I am sure they will be benefited from this website.

  27. Elvira 2019年7月10日 下午5:55

    I would like to thank you for the efforts you’ve put in penning this blog.
    I really hope to check out the same high-grade blog posts
    from you in the future as well. In truth, your creative writing abilities has motivated
    me to get my own site now 😉

  28. bit.ly 2019年6月29日 上午7:04

    For latest information you have to pay a quick visit world-wide-web and on the web I found this web page as
    a finest web page for latest updates.