{"id":73775,"date":"2024-02-26T10:51:24","date_gmt":"2024-02-26T02:51:24","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=73775"},"modified":"2024-02-26T10:51:38","modified_gmt":"2024-02-26T02:51:38","slug":"php-%e6%9c%89%e5%93%aa%e4%ba%9b%e5%a5%bd%e7%94%a8%e7%9a%84%e6%89%a9%e5%b1%95%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/73775.html","title":{"rendered":"PHP \u6709\u54ea\u4e9b\u597d\u7528\u7684\u6269\u5c55\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-73776\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/02\/img-w8futyCG9OMHb5iQEX87arig.png?x-oss-process=image\/auto-orient,1\/format,webp\" width=\"600\" height=\"342\" alt=\"PHP \u6709\u54ea\u4e9b\u597d\u7528\u7684\u6269\u5c55\u5e93\" \/><\/p>\n<p>### PHP \u6709\u54ea\u4e9b\u597d\u7528\u7684\u6269\u5c55\u5e93\uff1f<\/p>\n<p>\u5728PHP\u7684\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c<strong>\u6269\u5c55\u5e93<\/strong>\u8d77\u7740\u81f3\u5173\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u5b83\u4eec\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u989d\u5916\u7684\u529f\u80fd\u548c\u5de5\u5177\uff0c\u4ee5\u4fbf\u66f4\u9ad8\u6548\u5730\u7f16\u5199\u4ee3\u7801\u3001\u5904\u7406\u6570\u636e\u4ee5\u53ca\u6267\u884c\u5404\u79cd\u4efb\u52a1\u3002<strong>\u6700\u53d7\u6b22\u8fce\u548c\u5b9e\u7528\u7684PHP\u6269\u5c55\u5e93\u5305\u62ecLaravel\u3001Symfony\u3001Guzzle\u3001PHPUnit\u3001\u4ee5\u53caRedis<\/strong>\u7b49\u3002\u8fd9\u4e9b\u5e93\u901a\u8fc7\u63d0\u4f9b\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u9ad8\u6548\u7684\u4ee3\u7801\u5b9e\u73b0\uff0c\u5927\u5927\u63d0\u9ad8\u4e86PHP\u5f00\u53d1\u7684\u6548\u7387\u548c\u8d28\u91cf\u3002\u5176\u4e2d\uff0c<strong>Laravel<\/strong>\u4f5c\u4e3aPHP\u6846\u67b6\uff0c\u56e0\u5176\u4f18\u96c5\u7684\u8bed\u6cd5\u3001\u53ef\u7ef4\u62a4\u6027\u9ad8\u4ee5\u53ca\u4e30\u5bcc\u7684\u529f\u80fd\u96c6\u800c\u53d7\u5230\u5e7f\u6cdb\u63a8\u5d07\u3002Laravel\u4e0d\u4ec5\u652f\u6301MVC\uff08\u6a21\u578b-\u89c6\u56fe-\u63a7\u5236\u5668\uff09\u67b6\u6784\u6a21\u5f0f\uff0c\u4f7f\u5f97\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u66f4\u52a0\u7ec4\u7ec7\u5316\uff0c\u8fd8\u63d0\u4f9b\u4e86\u6613\u4e8e\u4f7f\u7528\u7684\u8def\u7531\u3001\u4f1a\u8bdd\u3001\u7f13\u5b58\u4ee5\u53ca\u8ba4\u8bc1\u673a\u5236\uff0c\u6781\u5927\u5730\u7b80\u5316\u4e86Web\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u3002<\/p>\n<p>### \u4e00\u3001LARAVEL\uff1aPHP\u5f00\u53d1\u7684\u9769\u547d<\/p>\n<p><strong>Laravel<\/strong>\u662f\u4e00\u4e2a\u4e3aWeb\u827a\u672f\u5bb6\u521b\u5efa\u7684PHP\u6846\u67b6\uff0c\u65e8\u5728\u7b80\u5316\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u7684\u4efb\u52a1\uff0c\u5982\u8def\u7531\u3001\u4f1a\u8bdd\u3001\u7f13\u5b58\u548c\u8ba4\u8bc1\u3002Laravel\u91c7\u7528\u4e86MVC\u67b6\u6784\uff0c\u8fd9\u4e0d\u4ec5\u5e2e\u52a9\u5f00\u53d1\u8005\u4ee5\u66f4\u6e05\u6670\u7684\u65b9\u5f0f\u7ec4\u7ec7\u4ee3\u7801\uff0c\u8fd8\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u590d\u7528\u6027\u548c\u6a21\u5757\u5316\u3002Laravel\u7684Eloquent ORM\uff08\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff09\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7f8e\u89c2\u3001\u7b80\u6d01\u7684ActiveRecord\u5b9e\u73b0\uff0c\u7528\u4e8e\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u3002\u6b64\u5916\uff0cLaravel\u7684\u8fc1\u79fb\u7cfb\u7edf\u4e3a\u6570\u636e\u5e93\u7684\u7248\u672c\u63a7\u5236\u548c\u56e2\u961f\u534f\u4f5c\u63d0\u4f9b\u4e86\u4fbf\u5229\u3002\u8fd9\u4e9b\u7279\u70b9\u4f7fLaravel\u6210\u4e3a\u5f00\u53d1\u590d\u6742\u5e94\u7528\u7a0b\u5e8f\u7684\u9996\u9009\u6846\u67b6\u3002<\/p>\n<p>Laravel\u793e\u533a\u975e\u5e38\u6d3b\u8dc3\uff0c\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u6559\u7a0b\u3001\u8d44\u6e90\u548c\u7b2c\u4e09\u65b9\u5305\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u5feb\u901f\u5b66\u4e60\u548c\u4f7f\u7528\u8fd9\u4e2a\u6846\u67b6\u3002Laravel\u7684\u5305\u7ba1\u7406\u5668Composer\u8fdb\u4e00\u6b65\u7b80\u5316\u4e86\u7b2c\u4e09\u65b9\u5305\u7684\u5b89\u88c5\u548c\u7ba1\u7406\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u8f7b\u677e\u5730\u6dfb\u52a0\u529f\u80fd\u548c\u6a21\u5757\u5230\u4ed6\u4eec\u7684\u5e94\u7528\u4e2d\u3002<\/p>\n<p>### \u4e8c\u3001SYMFONY\uff1a\u6784\u5efa\u9ad8\u6027\u80fd\u5e94\u7528\u7684\u6846\u67b6<\/p>\n<p>Symfony\u662f\u53e6\u4e00\u4e2a\u6d41\u884c\u7684PHP\u6846\u67b6\uff0c\u5b83\u4e3a\u5f00\u53d1\u590d\u6742\u7684\u4f01\u4e1a\u7ea7\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u53ef\u9760\u7684\u57fa\u7840\u3002<strong>Symfony<\/strong>\u4ee5\u5176\u7ec4\u4ef6\u4e3a\u57fa\u7840\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u9009\u62e9\u6027\u5730\u4f7f\u7528\u8fd9\u4e9b\u7ec4\u4ef6\u6765\u6784\u5efa\u81ea\u5df1\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u8fd9\u4e3aPHP\u5f00\u53d1\u5e26\u6765\u4e86\u6781\u5927\u7684\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5c55\u6027\u3002Symfony\u7684HTTPFoundation\u7ec4\u4ef6\u6539\u53d8\u4e86PHP\u9879\u76ee\u5904\u7406\u8bf7\u6c42\u548c\u54cd\u5e94\u7684\u65b9\u5f0f\uff0c\u4e3a\u521b\u5efa\u54cd\u5e94\u5f0fWeb\u5e94\u7528\u7a0b\u5e8f\u548c\u670d\u52a1\u63d0\u4f9b\u4e86\u575a\u5b9e\u7684\u57fa\u7840\u3002<\/p>\n<p>Symfony\u793e\u533a\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u6587\u6863\u3001\u6559\u7a0b\u548c\u63d2\u4ef6\uff0c\u652f\u6301\u5f00\u53d1\u8005\u5feb\u901f\u4e0a\u624b\u548c\u6df1\u5165\u5b66\u4e60\u3002\u6b64\u5916\uff0cSymfony\u7684Doctrine ORM\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5e93\u62bd\u8c61\u5c42\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u6d01\u7684\u65b9\u5f0f\u6765\u64cd\u4f5c\u6570\u636e\u5e93\u3002<\/p>\n<p>### \u4e09\u3001GUZZLE\uff1aPHP\u7684HTTP\u5ba2\u6237\u7aef<\/p>\n<p><strong>Guzzle<\/strong>\u662f\u4e00\u4e2aPHP\u7684HTTP\u5ba2\u6237\u7aef\uff0c\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\u548c\u63a5\u6536\u54cd\u5e94\u3002Guzzle\u7684\u7279\u70b9\u662f\u6613\u4e8e\u4f7f\u7528\u4e14\u529f\u80fd\u5f3a\u5927\uff0c\u652f\u6301\u540c\u6b65\u548c\u5f02\u6b65\u8bf7\u6c42\uff0c\u4f7f\u5f97\u5b83\u6210\u4e3a\u5904\u7406Web\u670d\u52a1\u548cAPI\u8c03\u7528\u7684\u7406\u60f3\u9009\u62e9\u3002Guzzle\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e30\u5bcc\u7684\u63a5\u53e3\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u6784\u5efa\u67e5\u8be2\u5b57\u7b26\u4e32\u3001POST\u8bf7\u6c42\u3001\u4e0a\u4f20\u6587\u4ef6\u7b49\u590d\u6742\u7684HTTP\u8bf7\u6c42\u3002<\/p>\n<p>\u901a\u8fc7Guzzle\uff0cPHP\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u4e0e\u7b2c\u4e09\u65b9API\u7684\u96c6\u6210\uff0c\u5982\u793e\u4ea4\u5a92\u4f53\u670d\u52a1\u3001\u652f\u4ed8\u7f51\u5173\u548c\u6570\u636e\u63d0\u4f9b\u5546\u7b49\u3002Guzzle\u7684\u53e6\u4e00\u4e2a\u4eae\u70b9\u662f\u5b83\u7684\u4e2d\u95f4\u4ef6\u7cfb\u7edf\uff0c\u5141\u8bb8\u5f00\u53d1<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u6709\u54ea\u4e9b\u6d41\u884c\u7684PHP\u6269\u5c55\u5e93\uff1f<\/strong><\/p>\n<p>\u6709\u8bb8\u591a\u6d41\u884c\u7684PHP\u6269\u5c55\u5e93\u53ef\u4f9b\u9009\u62e9\uff0c\u5176\u4e2d\u4e00\u4e9b\u5305\u62ec\uff1a<br \/>\n1. <strong>PDO<\/strong>\uff1aPHP\u6570\u636e\u5bf9\u8c61\uff08PDO\uff09\u5e93\u5141\u8bb8PHP\u4e0e\u591a\u79cd\u6570\u636e\u5e93\u8fdb\u884c\u4ea4\u4e92\uff0c\u5982MySQL\u3001PostgreSQL\u7b49\u3002<br \/>\n2. <strong>GD<\/strong>\uff1aGD\u5e93\u63d0\u4f9b\u4e86PHP\u64cd\u4f5c\u56fe\u50cf\u7684\u529f\u80fd\uff0c\u5305\u62ec\u521b\u5efa\u7f29\u7565\u56fe\u3001\u6dfb\u52a0\u6c34\u5370\u7b49\u3002<br \/>\n3. <strong>Memcached<\/strong>\uff1aMemcached\u6269\u5c55\u5e93\u53ef\u4ee5\u4e0eMemcached\u670d\u52a1\u5668\u8fdb\u884c\u4ea4\u4e92\uff0c\u7528\u4e8e\u5728\u5185\u5b58\u4e2d\u5b58\u50a8\u952e\u503c\u5bf9\u7b49\u7f13\u5b58\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5b89\u88c5PHP\u6269\u5c55\u5e93\uff1f<\/strong><\/p>\n<p>\u5b89\u88c5PHP\u6269\u5c55\u5e93\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7PECL\uff08PHP\u6269\u5c55\u793e\u533a\u5e93\uff09\u6216\u624b\u52a8\u7f16\u8bd1\u6e90\u4ee3\u7801\u6765\u5b9e\u73b0\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5PHP\u6269\u5c55\u5e93\u7684\u4e00\u822c\u6b65\u9aa4\uff1a<br \/>\n1. \u4e0b\u8f7d\u6269\u5c55\u5e93\u6e90\u4ee3\u7801\u6216\u901a\u8fc7PECL\u5b89\u88c5\u3002<br \/>\n2. \u89e3\u538b\u6e90\u4ee3\u7801\uff08\u5982\u679c\u662f\u6e90\u4ee3\u7801\u5b89\u88c5\uff09\u3002<br \/>\n3. \u8fd0\u884c`phpize`\u547d\u4ee4\u8fdb\u884c\u914d\u7f6e\u3002<br \/>\n4. \u8fd0\u884c`.\/configure`\u547d\u4ee4\u68c0\u67e5\u4f9d\u8d56\u5e76\u751f\u6210Makefile\u3002<br \/>\n5. \u8fd0\u884c`make`\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\u3002<br \/>\n6. \u8fd0\u884c`make install`\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>PHP\u6269\u5c55\u5e93\u5982\u4f55\u63d0\u9ad8\u7f51\u7ad9\u6027\u80fd\uff1f<\/strong><\/p>\n<p>\u4f7f\u7528PHP\u6269\u5c55\u5e93\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u7f51\u7ad9\u6027\u80fd\uff0c\u4f8b\u5982\uff1a<br \/>\n1. <strong>\u52a0\u901f\u7f13\u5b58<\/strong>\uff1a\u4f7f\u7528Memcached\u7b49\u6269\u5c55\u5e93\u53ef\u4ee5\u52a0\u901f\u6570\u636e\u8bbf\u95ee\uff0c\u51cf\u8f7b\u6570\u636e\u5e93\u8d1f\u62c5\u3002<br \/>\n2. <strong>\u5e76\u884c\u5904\u7406<\/strong>\uff1a\u90e8\u5206\u6269\u5c55\u5e93\u652f\u6301\u5e76\u884c\u5904\u7406\uff0c\u53ef\u540c\u65f6\u6267\u884c\u591a\u4e2a\u4efb\u52a1\uff0c\u63d0\u9ad8\u5904\u7406\u6548\u7387\u3002<br \/>\n3. <strong>\u4f18\u5316\u56fe\u7247\u5904\u7406<\/strong>\uff1aGD\u5e93\u7b49\u6269\u5c55\u5e93\u53ef\u4ee5\u4f18\u5316\u56fe\u50cf\u5904\u7406\uff0c\u51cf\u5c11\u52a0\u8f7d\u65f6\u95f4\u3002<\/p>\n<p>\u901a\u8fc7\u9009\u62e9\u9002\u5f53\u7684PHP\u6269\u5c55\u5e93\uff0c\u5e76\u7ed3\u5408\u5408\u7406\u7684\u4f18\u5316\u7b56\u7565\uff0c\u53ef\u4ee5\u6709\u6548\u63d0\u5347\u7f51\u7ad9\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"### PHP \u6709\u54ea\u4e9b\u597d\u7528\u7684\u6269\u5c55\u5e93\uff1f \u5728PHP\u7684\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6269\u5c55\u5e93\u8d77\u7740\u81f3\u5173\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u5b83\u4eec\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u989d\u5916\u7684 [&hellip;]","protected":false},"author":1,"featured_media":73778,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/73775"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=73775"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/73775\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/73778"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=73775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=73775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=73775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}