{"id":254,"date":"2015-08-07T21:03:16","date_gmt":"2015-08-07T13:03:16","guid":{"rendered":"https:\/\/blog.kotori.moe\/?p=254"},"modified":"2015-08-07T21:03:16","modified_gmt":"2015-08-07T13:03:16","slug":"laravel-5-1%e5%88%9d%e6%8e%a2","status":"publish","type":"post","link":"https:\/\/sora.sound.moe\/?p=254","title":{"rendered":"Laravel 5.1\u521d\u63a2"},"content":{"rendered":"<p>\u4e4b\u524d\u56e0\u4e3a\u8981\u5199\u4e00\u4e2a\u5c0f\u9879\u76ee\u73a9\uff0c\u53bb\u770b\u4e86\u5f88\u591aphp\u7684\u6846\u67b6\uff0c\u6700\u540e\u53d1\u73b0\u5176\u5b9eLaravel\u662f\u540d\u526f\u5176\u5b9e\u7684\u4f18\u96c5\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u5bf9\u4e8e\u5b89\u88c5\uff0cLaravel\u5e76\u4e0d\u7b80\u5355\uff0c\u5443\uff0c\u5176\u5b9e\u4e5f\u7b80\u5355\uff0c\u8bf4\u5e76\u4e0d\u7b80\u5355\u7684\u539f\u56e0\u662f\u8fd8\u6709\u4e2a\u89e3\u538b\u5373\u7528\u7684ThinkPHP\u2026\u2026<\/p>\n<p>\u4e3a\u4e86\u5b89\u88c5Laravel\u9700\u8981\u5148\u5b89\u88c5Composer\uff0c\u542c\u8bf4\u8fd9\u73a9\u610f\u8fd8\u662f\u633a\u597d\u7528\u7684\uff0c\u4e0d\u8fc7\u6211\u8fd8\u4e0d\u5927\u4f1a\u7528\u3002Win\u4e0b\u76f4\u63a5\u4e0b\u7f16\u8bd1\u8fc7\u7684\u5b89\u88c5\u5305\u5c31\u884c\u4e86\u3002<\/p>\n<pre class=\"lang:default decode:true \">composer global require \"laravel\/installer=~1.1\"<\/pre>\n<p>\u7136\u540e\u628a<span class=\"token operator\">~<\/span><span class=\"token operator\">\/<\/span><span class=\"token punctuation\">.<\/span>composer<span class=\"token operator\">\/<\/span>vendor<span class=\"token operator\">\/<\/span>bin\u52a0\u5165\u73af\u5883\u53d8\u91cf\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u5728\u547d\u4ee4\u884c\u4f7f\u7528laravel\u4e86\u3002<\/p>\n<p>Web\u8bbf\u95ee\u5165\u53e3\u5728Public\u76ee\u5f55\uff0c\u5982\u679c\u51fa\u73b0\u4e00\u4e9b\u5947\u602a\u9519\u8bef\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u751f\u6210\u4e00\u4e2a\u5bc6\u94a5\uff08\u5728\u9879\u76ee\u76ee\u5f55\u6267\u884cphp artisan key<span class=\"token punctuation\">:<\/span>generate\uff09\u3002<\/p>\n<p>Laravel\u7684\u8def\u7531\u662f\u624b\u52a8\u7684\uff0c\u9700\u8981\u5728routes.php\u4e2d\u624b\u52a8\u6307\u5b9a\uff0c\u5bf9\u4e8e\u8bbf\u95ee\u53ef\u4ee5\u7528\u95ed\u5305\u8fd4\u56de\u4e5f\u53ef\u4ee5\u4ea4\u7ed9Controller\u6216\u8005\u4e0eMiddleware\u76f8\u7ed3\u5408\u4ec0\u4e48\u7684\u3002Middleware\u7684\u6982\u5ff5\u6211\u5012\u662f\u7b2c\u4e00\u6b21\u63a5\u89e6\uff0c\u4e0d\u8fc7\u7528\u6765\u505a\u767b\u5f55\u9a8c\u8bc1\u4ec0\u4e48\u7684\uff0c\u786e\u5b9e\u662f\u601d\u8def\u4f18\u96c5\u3002<\/p>\n<p>\u8def\u7531\u7684\u7ed1\u5b9a\u662f\u5f88\u65b9\u4fbf\u7684\uff0c\u8c03\u7528Route\u7c7b\u7684\u9759\u6001\u65b9\u6cd5\u5373\u53ef\uff0c\u652f\u6301RESTful\u3002<\/p>\n<pre class=\"lang:php decode:true \">Route::get('\/', function () {\n    return 'Hello World';\n});\n\nRoute::post('foo\/bar', function () {\n    return 'Hello World';\n});\n\nRoute::put('foo\/bar', function () {\n    \/\/\n});\n\nRoute::delete('foo\/bar', function () {\n    \/\/\n});<\/pre>\n<p>\u603b\u4e4b\u66f4\u591a\u7684\u5c31\u67e5\u6587\u6863\u5427\uff0cLaravel\u7684\u6587\u6863\u662f\u76f8\u5f53\u4e0d\u5b8c\u5584\u7684\uff0c\u8bf7\u914d\u5408Google\u4f7f\u7528\u3002<\/p>\n<p>Laravel\u662f\u7eafOOP\uff0c\u800c\u4e14MVC\uff0c\u8fd9\u4fe9\u6211\u90fd\u5f88\u559c\u6b22\uff0c\u4ee5\u540e\u8fd8\u662f\u8981\u6df1\u5165\u7814\u7a76\u4e00\u4e0bLaravel\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u56e0\u4e3a\u8981\u5199\u4e00\u4e2a\u5c0f\u9879\u76ee\u73a9\uff0c\u53bb\u770b\u4e86\u5f88\u591aphp\u7684\u6846\u67b6\uff0c\u6700\u540e\u53d1\u73b0\u5176\u5b9eLaravel\u662f\u540d\u526f\u5176\u5b9e\u7684\u4f18\u96c5\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[17],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"twentyseventeen-featured-image":false,"twentyseventeen-thumbnail-avatar":false},"uagb_author_info":{"display_name":"Sora","author_link":"https:\/\/sora.sound.moe\/?author=1"},"uagb_comment_info":17,"uagb_excerpt":"\u4e4b\u524d\u56e0\u4e3a\u8981\u5199\u4e00\u4e2a\u5c0f\u9879\u76ee\u73a9\uff0c\u53bb\u770b\u4e86\u5f88\u591aphp\u7684\u6846\u67b6\uff0c\u6700\u540e\u53d1\u73b0\u5176\u5b9eLaravel\u662f\u540d\u526f\u5176\u5b9e\u7684\u4f18\u96c5\u3002","_links":{"self":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts\/254"}],"collection":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=254"}],"version-history":[{"count":0,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts\/254\/revisions"}],"wp:attachment":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}