{"id":48107,"date":"2024-12-02T09:11:34","date_gmt":"2024-12-02T01:11:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48107\/"},"modified":"2024-12-02T09:11:34","modified_gmt":"2024-12-02T01:11:34","slug":"php%e5%87%bd%e6%95%b0%e6%80%a7%e8%83%bd%e5%88%86%e6%9e%90%e5%b7%a5%e5%85%b7%e4%bb%8b%e7%bb%8d%ef%bc%9a%e5%b8%b8%e8%a7%81%e9%97%ae%e9%a2%98%e8%a7%a3%e7%ad%94","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48107\/","title":{"rendered":"php\u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>php\u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/h1>\n<p>IT\u884c\u4e1a\u76f8\u5bf9\u4e8e\u4e00\u822c\u4f20\u7edf\u884c\u4e1a\uff0c\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u66f4\u5feb\uff0c\u4e00\u65e6\u505c\u6b62\u4e86\u5b66\u4e60\uff0c\u5f88\u5feb\u5c31\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u6240\u4ee5\u6211\u4eec\u9700\u8981\u8e0f\u8e0f\u5b9e\u5b9e\u7684\u4e0d\u65ad\u5b66\u4e60\uff0c\u7cbe\u8fdb\u81ea\u5df1\u7684\u6280\u672f\uff0c\u5c24\u5176\u662f\u521d\u5b66\u8005\u3002\u4eca\u5929\u7c73\u4e91\u7ed9\u5927\u5bb6\u6574\u7406\u4e86\u300aphp\u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u300b\uff0c\u804a\u804a\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01<\/p>\n<p>Blackfire \u662f\u4e00\u6b3e PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5668\uff0c\u7528\u4e8e\u5256\u6790\u51fd\u6570\u6027\u80fd\u5e76\u8bc6\u522b\u74f6\u9888\u3002\u5e38\u89c1\u95ee\u9898\u5305\u62ec\uff1a\u5982\u4f55\u5b89\u88c5 Blackfire\uff1f\u7b54\uff1a\u4f7f\u7528 Composer \u6216 PECL \u5b89\u88c5\u3002\u5982\u4f55\u5bf9\u51fd\u6570\u8fdb\u884c\u5256\u6790\uff1f\u7b54\uff1a\u542f\u7528\u5256\u6790\u5668\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u5f85\u5256\u6790\u7684\u4ee3\u7801\u5468\u56f4\u3002\u5256\u6790\u7ed3\u679c\u5728\u54ea\u91cc\u53ef\u4ee5\u67e5\u770b\uff1f\u7b54\uff1a\u4fdd\u5b58\u5728\u6587\u4ef6\u4e2d\uff0c\u53ef\u4f7f\u7528 Web \u754c\u9762\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u3002\u5982\u4f55\u8bc6\u522b\u74f6\u9888\uff1f\u7b54\uff1a\u5256\u6790\u62a5\u544a\u7a81\u51fa\u663e\u793a\u8c03\u7528\u6b21\u6570\u548c\u6267\u884c\u65f6\u95f4\u6700\u9ad8\u7684\u51fd\u6570\u3002\u5982\u4f55\u4f18\u5316\u6027\u80fd\uff1f\u7b54\uff1a\u4f18\u5316\u74f6\u9888\u51fd\u6570\uff0c\u4f8b\u5982\u51cf\u5c11\u8c03\u7528\u6b21\u6570\u6216\u4f7f\u7528\u7f13\u5b58<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241027\/1729989638671d8c06c6fb2.jpg\" class=\"aligncenter\" title=\"php\u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u63d2\u56fe\" alt=\"php\u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/strong><\/p>\n<p><strong>\u7b80\u4ecb<\/strong><\/p>\n<p>\u5728 PHP \u4e2d\u4f18\u5316\u51fd\u6570\u6027\u80fd\u81f3\u5173\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u6027\u80fd\u3002\u6709\u4e00\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u5206\u6790\u51fd\u6570\u6027\u80fd\uff0c\u786e\u5b9a\u74f6\u9888\u5e76\u91c7\u53d6\u7ea0\u6b63\u63aa\u65bd\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u4e2a\u6d41\u884c\u7684 PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\uff0c\u5e76\u56de\u7b54\u6709\u5173\u5176\u4f7f\u7528\u7684\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002<\/p>\n<p><strong>\u63a8\u8350\u5de5\u5177\uff1aBlackfire<\/strong><\/p>\n<p>Blackfire \u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684 PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5668\uff0c\u53ef\u63d0\u4f9b\u8be6\u7ec6\u7684\u5256\u6790\u62a5\u544a\uff0c\u5305\u62ec\u51fd\u6570\u8c03\u7528\u6b21\u6570\u3001\u6267\u884c\u65f6\u95f4\u3001\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u7b49\u6570\u636e\u3002<\/p>\n<p><strong>\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/strong><\/p>\n<p><strong>\u95ee\uff1a\u5982\u4f55\u5b89\u88c5 Blackfire\uff1f<\/strong><\/p>\n<p><strong>\u7b54\uff1a<\/strong>\u4f7f\u7528 Composer\uff1a<\/p>\n<pre>composer require blackfire\/blackfire<\/pre>\n<p>\u6216\u4f7f\u7528 PECL\uff1a<\/p>\n<pre>pecl install blackfire<\/pre>\n<p><strong>\u95ee\uff1a\u5982\u4f55\u5bf9\u51fd\u6570\u8fdb\u884c\u5256\u6790\uff1f<\/strong><\/p>\n<p><strong>\u7b54\uff1a<\/strong>\u5728\u8981\u5256\u6790\u7684\u4ee3\u7801\u4e4b\u524d\u4f7f\u7528 <code>BlackfireProfiler::enable()<\/code> \u51fd\u6570\u542f\u7528\u5256\u6790\u5668\uff0c\u5e76\u5728\u4e4b\u540e\u4f7f\u7528 <code>BlackfireProfiler::disable()<\/code> \u7981\u7528\u5b83\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>BlackfireProfiler::enable();\n\n\/\/ \u8981\u5256\u6790\u7684\u4ee3\u7801\n\nBlackfireProfiler::disable();<\/pre>\n<p><strong>\u95ee\uff1a\u5728\u54ea\u91cc\u53ef\u4ee5\u67e5\u770b\u5256\u6790\u7ed3\u679c\uff1f<\/strong><\/p>\n<p><strong>\u7b54\uff1a<\/strong>\u5256\u6790\u7ed3\u679c\u5c06\u4fdd\u5b58\u5728\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e3a <code>blackfire.prof<\/code>\uff09\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 Blackfire Web \u754c\u9762\u6216\u547d\u4ee4\u884c\u5de5\u5177 <code>blackfire report<\/code> \u67e5\u770b\u8fd9\u4e9b\u7ed3\u679c\u3002<\/p>\n<p><strong>\u95ee\uff1a\u5982\u4f55\u4ece\u5256\u6790\u7ed3\u679c\u4e2d\u8bc6\u522b\u74f6\u9888\uff1f<\/strong><\/p>\n<p><strong>\u7b54\uff1a<\/strong>\u5256\u6790\u62a5\u544a\u4f1a\u7a81\u51fa\u663e\u793a\u51fd\u6570\u6267\u884c\u6b21\u6570\u548c\u65f6\u95f4\u6700\u9ad8\u7684\u51fd\u6570\u3002\u8fd9\u4e9b\u51fd\u6570\u53ef\u80fd\u662f\u6f5c\u5728\u7684\u74f6\u9888\u3002<\/p>\n<p><strong>\u95ee\uff1a\u5982\u4f55\u4f7f\u7528\u5256\u6790\u7ed3\u679c\u6765\u63d0\u9ad8\u6027\u80fd\uff1f<\/strong><\/p>\n<p><strong>\u7b54\uff1a<\/strong>\u8bc6\u522b\u74f6\u9888\u540e\uff0c\u60a8\u53ef\u4ee5\u91c7\u53d6\u63aa\u65bd\u6765\u4f18\u5316\u8fd9\u4e9b\u51fd\u6570\u3002\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u91cd\u6784\u4ee3\u7801\u4ee5\u51cf\u5c11\u51fd\u6570\u8c03\u7528\u6b21\u6570<\/li>\n<li>\u4f7f\u7528\u7f13\u5b58\u673a\u5236<\/li>\n<li>\u4f18\u5316\u67e5\u8be2<\/li>\n<\/ul>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p>\u8ba9\u6211\u4eec\u4f7f\u7528 Blackfire \u5bf9\u4e00\u4e2a\u7b80\u5355\u7684 PHP \u51fd\u6570\u8fdb\u884c\u5256\u6790\uff1a<\/p>\n<pre>&lt;?php\n\nfunction sum($a, $b)\n{\n    return $a + $b;\n}\n\n$result = sum(1, 2);\n\n?&gt;<\/pre>\n<p>\u5bf9\u8be5\u4ee3\u7801\u8fdb\u884c\u5256\u6790\uff0c\u7ed3\u679c\u663e\u793a <code>sum()<\/code> \u51fd\u6570\u88ab\u8c03\u7528\u4e86\u4e00\u6b21\uff0c\u6267\u884c\u65f6\u95f4\u4e3a 0.001 \u79d2\u3002\u8fd9\u8868\u660e\u8be5\u51fd\u6570\u6ca1\u6709\u6027\u80fd\u95ee\u9898\u3002<\/p>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>Blackfire \u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684 PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\uff0c\u53ef\u5e2e\u52a9\u60a8\u8bc6\u522b\u74f6\u9888\u5e76\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u6027\u80fd\u3002\u901a\u8fc7\u4f7f\u7528\u5256\u6790\u7ed3\u679c\u7684\u6307\u5bfc\uff0c\u60a8\u53ef\u4ee5\u4f18\u5316\u4ee3\u7801\u5e76\u5b9e\u73b0\u660e\u663e\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n<p>\u4eca\u5929\u5173\u4e8e\u300aphp\u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u300b\u7684\u5185\u5bb9\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\uff0c\u5982\u679c\u6709\u4ec0\u4e48\u7591\u95ee\u6216\u8005\u5efa\u8bae\uff0c\u53ef\u4ee5\u5728\u7c73\u4e91\u516c\u4f17\u53f7\u4e0b\u591a\u591a\u56de\u590d\u4ea4\u6d41\uff1b\u6587\u4e2d\u82e5\u6709\u4e0d\u6b63\u4e4b\u5904\uff0c\u4e5f\u5e0c\u671b\u56de\u590d\u7559\u8a00\u4ee5\u544a\u77e5\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>php\u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54 IT\u884c\u4e1a\u76f8\u5bf9\u4e8e\u4e00\u822c\u4f20\u7edf\u884c\u4e1a\uff0c\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u66f4\u5feb\uff0c\u4e00\u65e6\u505c\u6b62\u4e86\u5b66\u4e60\uff0c\u5f88\u5feb\u5c31\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u6240\u4ee5\u6211\u4eec\u9700\u8981\u8e0f\u8e0f\u5b9e\u5b9e\u7684\u4e0d\u65ad\u5b66\u4e60\uff0c\u7cbe\u8fdb\u81ea\u5df1\u7684\u6280\u672f\uff0c\u5c24\u5176\u662f\u521d\u5b66\u8005\u3002\u4eca\u5929\u7c73\u4e91\u7ed9\u5927\u5bb6\u6574\u7406\u4e86\u300aphp\u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u300b\uff0c\u804a\u804a\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01 Blackfire \u662f\u4e00\u6b3e PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5668\uff0c\u7528\u4e8e\u5256\u6790\u51fd\u6570\u6027\u80fd\u5e76\u8bc6\u522b\u74f6\u9888\u3002\u5e38\u89c1\u95ee\u9898\u5305\u62ec\uff1a\u5982\u4f55\u5b89\u88c5 Blackfire\uff1f\u7b54\uff1a\u4f7f\u7528 Composer \u6216 PECL \u5b89\u88c5\u3002\u5982\u4f55\u5bf9\u51fd\u6570\u8fdb\u884c\u5256\u6790\uff1f\u7b54\uff1a\u542f\u7528\u5256\u6790\u5668\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u5f85\u5256\u6790\u7684\u4ee3\u7801\u5468\u56f4\u3002\u5256\u6790\u7ed3\u679c\u5728\u54ea\u91cc\u53ef\u4ee5\u67e5\u770b\uff1f\u7b54\uff1a\u4fdd\u5b58\u5728\u6587\u4ef6\u4e2d\uff0c\u53ef\u4f7f\u7528 Web \u754c\u9762\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u3002\u5982\u4f55\u8bc6\u522b\u74f6\u9888\uff1f\u7b54\uff1a\u5256\u6790\u62a5\u544a\u7a81\u51fa\u663e\u793a\u8c03\u7528\u6b21\u6570\u548c\u6267\u884c\u65f6\u95f4\u6700\u9ad8\u7684\u51fd\u6570\u3002\u5982\u4f55\u4f18\u5316\u6027\u80fd\uff1f\u7b54\uff1a\u4f18\u5316\u74f6\u9888\u51fd\u6570\uff0c\u4f8b\u5982\u51cf\u5c11\u8c03\u7528\u6b21\u6570\u6216\u4f7f\u7528\u7f13\u5b58 PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\u4ecb\u7ecd\uff1a\u5e38\u89c1\u95ee\u9898\u89e3\u7b54 \u7b80\u4ecb \u5728 PHP \u4e2d\u4f18\u5316\u51fd\u6570\u6027\u80fd\u81f3\u5173\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u6027\u80fd\u3002\u6709\u4e00\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u5206\u6790\u51fd\u6570\u6027\u80fd\uff0c\u786e\u5b9a\u74f6\u9888\u5e76\u91c7\u53d6\u7ea0\u6b63\u63aa\u65bd\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u4e2a\u6d41\u884c\u7684 PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5de5\u5177\uff0c\u5e76\u56de\u7b54\u6709\u5173\u5176\u4f7f\u7528\u7684\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002 \u63a8\u8350\u5de5\u5177\uff1aBlackfire Blackfire \u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684 PHP \u51fd\u6570\u6027\u80fd\u5206\u6790\u5668\uff0c\u53ef\u63d0\u4f9b\u8be6\u7ec6\u7684\u5256\u6790\u62a5\u544a\uff0c\u5305\u62ec\u51fd\u6570\u8c03\u7528\u6b21\u6570\u3001\u6267\u884c\u65f6\u95f4\u3001\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u7b49\u6570\u636e\u3002 \u5e38\u89c1\u95ee\u9898\u89e3\u7b54 \u95ee\uff1a\u5982\u4f55\u5b89\u88c5 Blackfire\uff1f \u7b54\uff1a\u4f7f\u7528 Composer\uff1a composer require blackfire\/blackfire \u6216\u4f7f\u7528 PECL\uff1a pecl install blackfire \u95ee\uff1a\u5982\u4f55\u5bf9\u51fd\u6570\u8fdb\u884c\u5256\u6790\uff1f \u7b54\uff1a\u5728\u8981\u5256\u6790\u7684\u4ee3\u7801\u4e4b\u524d\u4f7f\u7528 BlackfireProfiler::enable() \u51fd\u6570\u542f\u7528\u5256\u6790\u5668\uff0c\u5e76\u5728\u4e4b\u540e\u4f7f\u7528 BlackfireProfiler::disable() \u7981\u7528\u5b83\u3002\u4f8b\u5982\uff1a BlackfireProfiler::enable(); \/\/ \u8981\u5256\u6790\u7684\u4ee3\u7801 BlackfireProfiler::disable(); \u95ee\uff1a\u5728\u54ea\u91cc\u53ef\u4ee5\u67e5\u770b\u5256\u6790\u7ed3\u679c\uff1f \u7b54\uff1a\u5256\u6790\u7ed3\u679c\u5c06\u4fdd\u5b58\u5728\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e3a blackfire.prof\uff09\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 Blackfire Web \u754c\u9762\u6216\u547d\u4ee4\u884c\u5de5\u5177 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48107","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=48107"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48107\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}