{"id":2151,"date":"2016-09-23T13:02:00","date_gmt":"2016-09-23T05:02:00","guid":{"rendered":"http:\/\/www.zuola.com\/weblog\/2016\/09\/2151.htm"},"modified":"2016-09-23T13:02:00","modified_gmt":"2016-09-23T05:02:00","slug":"%e5%ae%89%e8%a3%85%e4%bd%bf%e7%94%a8restful-%e6%a1%86%e6%9e%b6slim%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/www.zuola.com\/weblog\/2016\/09\/2151.htm","title":{"rendered":"\u5b89\u88c5\u4f7f\u7528RESTful \u6846\u67b6SLIM\u7b14\u8bb0"},"content":{"rendered":"<p>RESTful API\u6846\u67b6\u6709\u5f88\u591a\uff0c\u5176\u4ed6\u8bed\u8a00\u4e0d\u719f\u6089\uff0c\u6211\u5c31\u627e\u4e86PHP\u7684\u3002\u7531\u4e8eSLIM\u7684<a href=\"http:\/\/www.slimphp.net\/docs\/\">\u6709\u4e2d\u6587\u6587\u6863<\/a>\uff0c\u9605\u8bfb\u8d77\u6765\u901f\u5ea6\u5feb\u8bb8\u591a\uff0c\u52a0\u4e4b<a href=\"https:\/\/zhujun24.github.io\/2015\/03\/19\/%E7%94%A8Slim%E8%BD%BB%E5%9E%8BPHP%E6%A1%86%E6%9E%B6%E5%86%99RESTful%20APIs\/\">\u8fd9\u7bc7\u6587\u7ae0<\/a>\u91cc\u6709\u975e\u5e38\u6613\u61c2\u7684\u793a\u4f8b\uff0c\u4e8e\u662f\u9009\u4e86<a href=\"https:\/\/github.com\/slimphp\/Slim\">SLIM<\/a>\u3002<\/p>\n<p>\u76f8\u5173\u6846\u67b6\uff1a<\/p>\n<ol>\n<li><a href=\"http:\/\/www.golaravel.com\/\">http:\/\/www.golaravel.com<\/a> \u662f\u4e00\u4e2aPHP\u6846\u67b6\uff0c\u5185\u7f6e\u540d\u4e3aLUMEN\u7684&nbsp;RESTful API\u6846\u67b6\uff0c\u6709\u4e2d\u6587\u6587\u6863\uff0c<a href=\"http:\/\/lumen.golaravel.com\/docs\/\">http:\/\/lumen.golaravel.com\/docs\/<\/a>&nbsp;<\/li>\n<li><a href=\"https:\/\/apigility.org\/\">https:\/\/apigility.org<\/a>\/ \u662f\u57fa\u4e8eZEND\u6846\u67b6\u7684&nbsp;RESTful API\u6846\u67b6 \u3002<\/li>\n<li><a href=\"https:\/\/github.com\/anandkunal\/ToroPHP\">https:\/\/github.com\/anandkunal\/ToroPHP<\/a>&nbsp;<span style=\"background-color: white; color: #333333; font-family: , &quot;blinkmacsystemfont&quot; , &quot;segoe ui&quot; , &quot;roboto&quot; , &quot;helvetica&quot; , &quot;arial&quot; , sans-serif , &quot;apple color emoji&quot; , &quot;segoe ui emoji&quot; , &quot;segoe ui symbol&quot;; font-size: 16px;\">Toro is a PHP router for developing RESTful web applications and APIs. It is designed for minimalists who want to get work done.&nbsp;<\/span><\/li>\n<li><span style=\"background-color: white; color: #333333; font-family: , &quot;blinkmacsystemfont&quot; , &quot;segoe ui&quot; , &quot;roboto&quot; , &quot;helvetica&quot; , &quot;arial&quot; , sans-serif , &quot;apple color emoji&quot; , &quot;segoe ui emoji&quot; , &quot;segoe ui symbol&quot;; font-size: 16px;\"><a href=\"https:\/\/github.com\/yiisoft\/yii2\/\">https:\/\/github.com\/yiisoft\/yii2\/<\/a> Yii PHP Framework Version 2 \uff0c<\/span><span style=\"background-color: white; color: #333333; font-family: , &quot;blinkmacsystemfont&quot; , &quot;segoe ui&quot; , &quot;roboto&quot; , &quot;helvetica&quot; , &quot;arial&quot; , sans-serif , &quot;apple color emoji&quot; , &quot;segoe ui emoji&quot; , &quot;segoe ui symbol&quot;; font-size: 16px;\">a modern PHP framework designed for professional Web development.<\/span><\/li>\n<\/ol>\n<p>SLIM\u4f9d\u8d56composer\u6765\u5b89\u88c5\uff0c\u4e0d\u7528composer\u5b89\u88c5\u8fd8\u86ee\u56f0\u96be\u7684\uff0c\u6ca1\u627e\u5230\u6559\u7a0b\u3002\u7ecf\u8fc7\u4e00\u7ffb\u6298\u817e\u540e\uff0c\u6211\u627e\u5230\u7b80\u4fbf\u7684\u5b89\u88c5\u65b9\u5f0f\u4e86\u3002<br \/><a name='more'><\/a>\u5148\u53bb&nbsp;<a href=\"https:\/\/getcomposer.org\/\">https:\/\/getcomposer.org<\/a> &nbsp; \u4e0b\u8f7d &nbsp;composer.phar<\/p>\n<pre style=\"background-color: white; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-color: rgb(238, 238, 238); border-style: solid; border-top-left-radius: 4px; border-top-right-radius: 4px; border-width: 0px 0px 0px 2px; box-sizing: border-box; color: #333333; font-family: Consolas, monospace; font-size: 15px; line-height: 23px; margin-bottom: 20px; margin-top: 20px; overflow: auto; padding: 14px 0px 14px 20px; word-break: break-all; word-wrap: normal;\">curl -sS https:\/\/getcomposer.org\/installer | php<\/pre>\n<p>composer.phar \u662f\u4e00\u4e2aPHP\u7684\u538b\u7f29\u5305\uff0c\u53ef\u76f4\u63a5\u8fd0\u884c\uff0c\u4e0d\u9700\u8981\u60f3\u529e\u6cd5\u89e3\u5f00\u3002<\/p>\n<p>\u7528<\/p>\n<pre style=\"background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;\">php composer.phar require slim\/slim \"^3.0\" <\/pre>\n<p>\u4ee3\u66ff&nbsp;<a href=\"https:\/\/github.com\/slimphp\/Slim\">https:\/\/github.com\/slimphp\/Slim<\/a> \u7684\u8bf4\u660e\u4e66\u4e2d\u63d0\u5230\u7684\uff1a<\/p>\n<pre style=\"background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;\">$ composer require slim\/slim <span style=\"box-sizing: border-box; color: #183691;\"><span style=\"box-sizing: border-box;\">\"<\/span>^3.0<span style=\"box-sizing: border-box;\">\"<\/span><\/span><\/pre>\n<p>\u8fd9\u6837\u76f8\u5173\u7684\u4f9d\u8d56\u5305\u90fd\u5b89\u88c5\u4e0a\u4e86\uff1a<\/p>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">$ php composer.phar require slim\/slim &#8220;^3.0&#8221;<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #34bc26; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">.\/composer.json has been created<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #34bc26; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">Loading composer repositories with package information<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #34bc26; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">Updating dependencies (including require-dev)<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #34bc26; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"color: #d6d6d6; font-variant-ligatures: no-common-ligatures;\">&nbsp; &#8211; Installing <\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">container-interop\/container-interop<\/span><span style=\"color: #d6d6d6; font-variant-ligatures: no-common-ligatures;\"> (<\/span><span style=\"color: #afad24; font-variant-ligatures: no-common-ligatures;\">1.1.0<\/span><span style=\"color: #d6d6d6; font-variant-ligatures: no-common-ligatures;\">)<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &nbsp; Loading from cache<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal; min-height: 30px;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &#8211; Installing <\/span><span style=\"color: #34bc26; font-variant-ligatures: no-common-ligatures;\">nikic\/fast-route<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> (<\/span><span style=\"color: #afad24; font-variant-ligatures: no-common-ligatures;\">v1.0.1<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">)<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &nbsp; Loading from cache<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal; min-height: 30px;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &#8211; Installing <\/span><span style=\"color: #34bc26; font-variant-ligatures: no-common-ligatures;\">psr\/http-message<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> (<\/span><span style=\"color: #afad24; font-variant-ligatures: no-common-ligatures;\">1.0.1<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">)<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &nbsp; Loading from cache<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal; min-height: 30px;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &#8211; Installing <\/span><span style=\"color: #34bc26; font-variant-ligatures: no-common-ligatures;\">pimple\/pimple<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> (<\/span><span style=\"color: #afad24; font-variant-ligatures: no-common-ligatures;\">v3.0.2<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">)<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &nbsp; Loading from cache<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal; min-height: 30px;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &#8211; Installing <\/span><span style=\"color: #34bc26; font-variant-ligatures: no-common-ligatures;\">slim\/slim<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> (<\/span><span style=\"color: #afad24; font-variant-ligatures: no-common-ligatures;\">3.5.0<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">)<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &nbsp; Downloading: <\/span><span style=\"color: #afad24; font-variant-ligatures: no-common-ligatures;\">100%<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal; min-height: 30px;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #34bc26; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">Writing lock file<\/span><\/div>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #34bc26; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">Generating autoload files<\/span><\/div>\n<p><\/p>\n<div style=\"background-color: rgba(0, 0, 0, 0.901961); color: #d6d6d6; font-family: 'Arial Unicode MS'; font-size: 22px; line-height: normal;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">gongzuola:myfavor.link zola$&nbsp;<\/span><\/div>\n<p>\u8fd9\u6837\u5c31\u5b89\u88c5\u597d\u4e86\u3002<\/p>\n<p>\u628asample \u6587\u4ef6\u5939\u91cc\u7684index.php \u548c .htaccess\u590d\u5236\u5230\u6839\u76ee\u5f55\u4e0b\u5c31\u53ef\u4ee5\u6d4b\u8bd5\u4e86\u3002<\/p>\n<p>\u8981\u8ba9API\u5de5\u4f5c\u8d77\u6765\uff0c\u5c31\u9700\u8981\u5199\u5bf9\u5e94\u7684SQL\u8bed\u53e5\uff0c\u5b9e\u73b0CRUD\u64cd\u4f5c\u4e86\u3002CRUD\u64cd\u4f5c\u662f\u5bf9\u6570\u636e\u5e93\u8fdb\u884ccreat\u3001read\u3001update\u3001delete\u64cd\u4f5c\u7684\u610f\u601d\u3002<\/p>\n<div>\u6765\u81ea\u5468\u66d9\u5149\u7684BLOGSPOT\u7a7a\u95f4<\/div>\n","protected":false},"excerpt":{"rendered":"<p>RESTful API\u6846\u67b6\u6709\u5f88\u591a\uff0c\u5176\u4ed6\u8bed\u8a00\u4e0d\u719f\u6089\uff0c\u6211\u5c31\u627e\u4e86PHP\u7684\u3002\u7531\u4e8eSLIM <span class=\"readmore\"><a href=\"https:\/\/www.zuola.com\/weblog\/2016\/09\/2151.htm\">Continue Reading &#8230;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2151","post","type-post","status-publish","format-standard","hentry","category-random"],"views":175,"_links":{"self":[{"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/posts\/2151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/comments?post=2151"}],"version-history":[{"count":0,"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/posts\/2151\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/media?parent=2151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/categories?post=2151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zuola.com\/weblog\/wp-json\/wp\/v2\/tags?post=2151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}