{"id":54315,"date":"2024-10-09T18:24:16","date_gmt":"2024-10-09T10:24:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/54315\/"},"modified":"2024-10-09T18:24:16","modified_gmt":"2024-10-09T10:24:16","slug":"windows-%e4%b8%8b%e5%ae%89%e8%a3%9d-pear-%e5%8f%8a-phpunit%ef%bc%88%e6%b3%a8%e6%84%8f%e9%85%8d%e7%bd%ae%e5%a5%bd-php-%e5%91%bd%e4%bb%a4%e8%a1%8c%e7%92%b0%e5%a2%83%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/54315\/","title":{"rendered":"Windows \u4e0b\u5b89\u88dd PEAR \u53ca PHPUnit\uff08\u6ce8\u610f\u914d\u7f6e\u597d PHP \u547d\u4ee4\u884c\u74b0\u5883\uff09"},"content":{"rendered":"<h1 id=\"windows-%e4%b8%8b%e5%ae%89%e8%a3%9d-pear-%e5%8f%8a-phpunit%ef%bc%88%e6%b3%a8%e6%84%8f%e9%85%8d%e7%bd%ae%e5%a5%bd-php-%e5%91%bd%e4%bb%a4%e8%a1%8c%e7%92%b0%e5%a2%83%ef%bc%89-yiigPxfcGq\">Windows \u4e0b\u5b89\u88dd PEAR \u53ca PHPUnit\uff08\u6ce8\u610f\u914d\u7f6e\u597d PHP \u547d\u4ee4\u884c\u74b0\u5883\uff09<\/h1>\n<p>\u5728 PHP \u958b\u767c\u4e2d\uff0cPEAR\uff08PHP Extension and Application Repository\uff09\u548c PHPUnit \u662f\u5169\u500b\u975e\u5e38\u91cd\u8981\u7684\u5de5\u5177\u3002PEAR \u63d0\u4f9b\u4e86\u4e00\u500b\u53ef\u91cd\u7528\u7684 PHP \u985e\u5eab\uff0c\u800c PHPUnit \u5247\u662f\u7528\u65bc\u55ae\u5143\u6e2c\u8a66\u7684\u6846\u67b6\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 Windows \u74b0\u5883\u4e0b\u5b89\u88dd PEAR \u548c PHPUnit\uff0c\u4e26\u78ba\u4fdd PHP \u547d\u4ee4\u884c\u74b0\u5883\u7684\u6b63\u78ba\u914d\u7f6e\u3002<\/p>\n<h2 id=\"%e4%b8%80%e3%80%81%e5%ae%89%e8%a3%9d-pear-yiigPxfcGq\">\u4e00\u3001\u5b89\u88dd PEAR<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u5df2\u7d93\u5b89\u88dd\u4e86 PHP\u3002\u53ef\u4ee5\u5f9e <a href=\"https:\/\/windows.php.net\/download\/\" rel=\"nofollow noopener\" target=\"_blank\">PHP \u5b98\u65b9\u7db2\u7ad9<\/a> \u4e0b\u8f09\u9069\u5408\u60a8\u7cfb\u7d71\u7684\u7248\u672c\u3002\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u8acb\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u5b89\u88dd PEAR\uff1a<\/p>\n<ol>\n<li>\u4e0b\u8f09 PEAR \u5b89\u88dd\u6a94\u6848\u3002\u60a8\u53ef\u4ee5\u5f9e <a href=\"https:\/\/pear.php.net\/go-pear.phar\" rel=\"nofollow noopener\" target=\"_blank\">\u9019\u88e1<\/a> \u4e0b\u8f09 go-pear.phar\u3002<\/li>\n<li>\u6253\u958b\u547d\u4ee4\u63d0\u793a\u5b57\u5143\uff08CMD\uff09\uff0c\u4e26\u5c0e\u822a\u5230\u60a8\u4e0b\u8f09 go-pear.phar \u7684\u76ee\u9304\u3002<\/li>\n<li>\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd PEAR\uff1a<\/li>\n<\/ol>\n<pre><code>php go-pear.phar<\/code><\/pre>\n<p>\u5728\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u7cfb\u7d71\u6703\u63d0\u793a\u60a8\u9078\u64c7\u5b89\u88dd\u8def\u5f91\uff0c\u901a\u5e38\u5efa\u8b70\u4f7f\u7528\u9810\u8a2d\u8def\u5f91\u3002\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 PEAR \u662f\u5426\u5b89\u88dd\u6210\u529f\uff1a<\/p>\n<pre><code>pear version<\/code><\/pre>\n<h2 id=\"%e4%ba%8c%e3%80%81%e9%85%8d%e7%bd%ae-php-%e5%91%bd%e4%bb%a4%e8%a1%8c%e7%92%b0%e5%a2%83-yiigPxfcGq\">\u4e8c\u3001\u914d\u7f6e PHP \u547d\u4ee4\u884c\u74b0\u5883<\/h2>\n<p>\u70ba\u4e86\u80fd\u5920\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528 PHP \u548c PEAR\uff0c\u60a8\u9700\u8981\u5c07 PHP \u7684\u5b89\u88dd\u76ee\u9304\u6dfb\u52a0\u5230\u7cfb\u7d71\u7684\u74b0\u5883\u8b8a\u91cf\u4e2d\u3002\u8acb\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\uff1a<\/p>\n<ol>\n<li>\u53f3\u9375\u9ede\u64ca\u201c\u6b64\u96fb\u8166\u201d\u6216\u201c\u6211\u7684\u96fb\u8166\u201d\uff0c\u9078\u64c7\u201c\u5c6c\u6027\u201d\u3002<\/li>\n<li>\u9ede\u64ca\u201c\u9ad8\u7d1a\u7cfb\u7d71\u8a2d\u7f6e\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7d71\u5c6c\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u9ede\u64ca\u201c\u74b0\u5883\u8b8a\u91cf\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7d71\u8b8a\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u4e26\u9078\u64c7\u201cPath\u201d\u8b8a\u91cf\uff0c\u7136\u5f8c\u9ede\u64ca\u201c\u7de8\u8f2f\u201d\u3002<\/li>\n<li>\u5728\u7de8\u8f2f\u7a97\u53e3\u4e2d\uff0c\u6dfb\u52a0 PHP \u7684\u5b89\u88dd\u8def\u5f91\uff0c\u4f8b\u5982\uff1aC:php\u3002<\/li>\n<li>\u9ede\u64ca\u201c\u78ba\u5b9a\u201d\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ol>\n<p>\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u91cd\u65b0\u555f\u52d5\u547d\u4ee4\u63d0\u793a\u5b57\u5143\uff0c\u4e26\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u78ba\u8a8d PHP \u662f\u5426\u914d\u7f6e\u6210\u529f\uff1a<\/p>\n<pre><code>php -v<\/code><\/pre>\n<h2 id=\"%e4%b8%89%e3%80%81%e5%ae%89%e8%a3%9d-phpunit-yiigPxfcGq\">\u4e09\u3001\u5b89\u88dd PHPUnit<\/h2>\n<p>\u5b89\u88dd\u5b8c PEAR \u4e4b\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 PEAR \u4f86\u5b89\u88dd PHPUnit\u3002\u8acb\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>pear install phpunit\/PHPUnit<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 PHPUnit \u662f\u5426\u5b89\u88dd\u6210\u529f\uff1a<\/p>\n<pre><code>phpunit --version<\/code><\/pre>\n<h2 id=\"%e5%9b%9b%e3%80%81%e4%bd%bf%e7%94%a8-phpunit-%e9%80%b2%e8%a1%8c%e5%96%ae%e5%85%83%e6%b8%ac%e8%a9%a6-yiigPxfcGq\">\u56db\u3001\u4f7f\u7528 PHPUnit \u9032\u884c\u55ae\u5143\u6e2c\u8a66<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u958b\u59cb\u4f7f\u7528 PHPUnit \u9032\u884c\u55ae\u5143\u6e2c\u8a66\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u7bc4\u4f8b\uff1a<\/p>\n<pre><code>class SampleTest extends PHPUnitFrameworkTestCase {\n    public function testAddition() {\n        $this-&gt;assertEquals(2, 1 + 1);\n    }\n}<\/code><\/pre>\n<p>\u5c07\u4e0a\u8ff0\u4ee3\u78bc\u4fdd\u5b58\u70ba SampleTest.php\uff0c\u7136\u5f8c\u5728\u547d\u4ee4\u884c\u4e2d\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u904b\u884c\u6e2c\u8a66\uff1a<\/p>\n<pre><code>phpunit SampleTest.php<\/code><\/pre>\n<p>\u5982\u679c\u6e2c\u8a66\u901a\u904e\uff0c\u60a8\u5c07\u770b\u5230\u76f8\u61c9\u7684\u6210\u529f\u6d88\u606f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-yiigPxfcGq\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Windows \u74b0\u5883\u4e0b\u5b89\u88dd PEAR \u548c PHPUnit \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\u3002\u901a\u904e\u6b63\u78ba\u914d\u7f6e PHP \u547d\u4ee4\u884c\u74b0\u5883\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u4f7f\u7528\u9019\u4e9b\u5de5\u5177\u4f86\u63d0\u9ad8\u958b\u767c\u6548\u7387\u548c\u4ee3\u78bc\u8cea\u91cf\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u958b\u767c\u74b0\u5883\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u4f86\u90e8\u7f72\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\uff0c\u9019\u5c07\u70ba\u60a8\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 Windows \u4e0a\u5b89\u88dd PEAR \u548c PHPUnit\uff0c\u4e26\u914d\u7f6e PHP \u547d\u4ee4\u884c\u74b0\u5883\u4ee5\u4fbf\u9806\u5229\u904b\u884c\u6e2c\u8a66\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-54315","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/54315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=54315"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/54315\/revisions"}],"predecessor-version":[{"id":54316,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/54315\/revisions\/54316"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=54315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=54315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=54315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}