2012.03.27 PHPåå¼·ä¼@æ±äº¬ #58
2012.03.27 PHPåå¼·ä¼@æ±äº¬ #58
èºèºãè絡ãç¡ããstartã ã¾ãã¯installã gitã§å¼ã£å¼µã£ã¦ãããã®ã§å¤§å¤ã«ããã¡ãã好ã¿ã é©å½ãªãã£ã¬ã¯ããªã«ããã¦ããã¾ãããã clone git://github.com/mlively/Phake.git phakeä»åã¯ãphakeãã£ã¦ãã£ã¬ã¯ããªã«ãã¦ããããç´ ç´ã¨ããããã¯åç´ã ã¾ãã使ãããããã«ããã ã¤ã³ã¹ãã¼ã«ãã£ã¬ã¯ããªãä¸ã®srcã«ãã¹ãéã£ã¦ãå¿ è¦ãããã£ã½ãã®ã§ãæä½éãããããªæãã $dir = "./phake/src/"; set_include_path(get_include_path() . ':' . $dir); require_once('Phake.php');é¢åã ããdirã¯ç¸å¯¾ãã¹ã ãã©ãæ¬å½ã¯çµ¶å¯¾ãã¹ã®ã»ããããã¨æãã MagicWeaponã ã¨ãconfigã®lib_pathã«è¿½å ããæããããã ããã§
4. PHPUnit - Advanced Features Mock Objects - A way to further isolate code while testing. Database Extension - A DBUnit port to allow creation of fixtures for database content. Selenium Integration - A gateway to integration testing. PHPUnderControl - Not really PHPUnit...but still very cool. Much to cover and not much of time. Let's get started! 5. PHPUnit - Mock Objects Mock Objects - A way to
src/Acme/DemoBundle/ ã«ãã¢ããããããããããã®ã½ã¼ã¹ãèªãã§ã¿ãã Twigé¢é£ã®è¨äºã ã»Twig - The flexible, fast, and secure template engine for PHP ã»ã¦ãã¦ã©ã by Zynga Japan: PHPãã³ãã¬ã¼ãã¨ã³ã¸ã³Twigãããã£ã¦ã¿ã¾ãã Symfony2ã¯require_onceãæ¸ããªããautoload.php ã«èªã¿è¾¼ããã£ã¬ã¯ããªãæ¸ãã ã»åçï¼ç¬¬4åSymfony2åå¼·ä¼ Symfony2ç³»ã®ãã³ãã«ã¯ãããã¦Symfony1ç³»ã§è¡¨ç¾ããã¨ã¢ããªã±ã¼ã·ã§ã³ã ãã©ãããããSymfony1ç³»ã¨æ¯è¼ããªããï¼å¥ç©ãªã®ã§ããï¼ â ãã£ã·ã¥ã®åé¤ ç¾ç¶ã1系㮠symfony cc ã®ãããªãã£ãã·ã¥ãåé¤ããã³ãã³ãã¯ãªãããã§ãã ãªã®ã§ãæåã§åé¤ãããããªãã¿ããã§ããrm
Symfonyã®æ©è½ãã¹ãã§ã¯æåã«WebTestCase::createClient()ã¡ã½ããã§Clientãªãã¸ã§ã¯ããä½æãããã®ãªãã¸ã§ã¯ãã使ã£ã¦ãªã¯ã¨ã¹ããè¡ãããã®è¿ãå¤ã確èªãããã¨ã«ãã£ã¦ãã¹ããè¡ãã¾ãã ãã¹ãã¯ã©ã¹: <?php ... class ...Test extends WebTestCase { public function test...() { $client = static::createClient(); $client->request('GET', '/path/to/foo'); $this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertThat($client->getCrawler()->filter('title')->text
Symfony2åå¼·ä¼ #6 ã§LTããã¦ãã¾ããã ã¾ã¨ã¾ãã®ãªãLTã«ãªã£ã¦ãã¾ããæãåºãã®ãæ¥ããããã®ã§ãããLTã®å 容ãè£è¶³ãã¾ãã ç®æ¬¡ LTã§è©±ããã㨠å人çã«é·ãã¨æã£ã¦ãããã¹ãã³ã¼ã åå²ããå¾ã®ãã¹ãã³ã¼ã(åãã¾ãã) containerããçæããtokenãä¸æ£ ãã¹ãæã®ã¿ãcsrfãç¡å¹ã«ããã¨ãæ§ã ãªå¼å®³ã CSRF対çãæå¹ãã©ãããå¤å®ããifæ DIããæ å ±ã¯ãç»é¢é·ç§»ã§åæåããã¦æ¶ãã 諸å 輩ããã®ã¢ããã¤ã¹ ãµãããã LTã§è©±ããã㨠Symfony2ã®ã³ã³ããã¼ã©ã®ãã¡ã³ã¯ã·ã§ãã«ãã¹ãã¯ãè¤æ°ã¢ã¯ã·ã§ã³ã«ã¾ãããã®ã§ä¸ã¤ä¸ã¤ã®ãã¹ãã±ã¼ã¹ãé·ããªããã¡ããã¹ãã±ã¼ã¹ãé·ãã¨ã¡ã³ããã³ã¹ãã¥ããã®ã§ãçãããããPOSTãªã¯ã¨ã¹ãã®ã¢ã¯ã·ã§ã³ããã¹ããããã¨ãã¦ãCSRF対çã«è¦ããã ãSessionãDIãã¦ãããã¹ãã±ã¼ã¹å ã§ç»é¢é·
è¦ç´Â¶ ãã®ç« ã«æ¥ãã¾ã§ã« Symfony2 ã§ã®éçºã«é¢ããã³ã¢ã®ã³ã³ã»ããã®å¤ãã®åéãè¦ã¦ãã¾ãããããã«æ©è½ã追å ããåã«ãããã§ãã¹ãã説æãã¦ããã¾ããããã¦ããããã¹ãã§åã ã®æ©è½ããã¹ãããæ¹æ³ãæ©è½ãã¹ãã§è¤æ°ã®ã³ã³ãã¼ãã³ãã®åä½ãæ£ãããã確èªããæ¹æ³ã®ä¸¡æ¹ãè¦ã¦ããã¾ãã Symfony2 ã®ãã¹ãã®ä¸å¿ã®ã©ã¤ãã©ãªã§ãã PHP ã®ãã¹ãã©ã¤ãã©ãª PHPUnit ã説æãã¾ãããã¹ãã¯éè¦ãªãããã¯ãªã®ã§ãå¾ã®ç« ã§ãæ±ãäºå®ã§ãããã®ç« ã®æå¾ã§ã¯ãã¦ããããã¹ããæ©è½ãã¹ãã®ä¸¡æ¹ã«ããå¤ãã®ãã¹ããæ¸ããã¨ã«ãªãã¾ãããã©ã¦ã¶ãã·ãã¥ã¬ã¼ããããããã©ã¼ã ã«ãã¼ã¿ãå ¥åããããã¦ã§ããã¼ã¸ãæ£ããåºåããã¦ãããã¬ã¹ãã³ã¹ããã§ãã¯ãããã¾ããã¾ããã¢ããªã±ã¼ã·ã§ã³ã®ã³ã¼ããã¼ã¹ã§ãã¹ããã©ã®ãããã®ã«ãã¬ãã¸ãªã®ããã§ãã¯ããã¾ãã Symfony2 ã«ããã
â»ãã£ã¡ãééã£ã¦ããã®ã§è¨æ£ãã¦ããã¾ã(2013/07/11) æè¿ã¯Symfony2ãªæ¥ã ãéã£ã¦ãã¾ãã ã¢ã¯ãã£ãã¬ã³ã¼ããã解æ¾ãããåã¯ããªã¼ãã ã§ãã ã§ããã£ã±ãDoctrine2ã§ãè«çåé¤ããããããã§ãã ãã ãã¡ãã£ã¨å°å ¥ããã£ããã¨ããããµã³ãã«ããªããªãè¦ã¤ãããªãã£ãã®ã§è¦èé²ã¨ãã¦ããã«æ®ãã¦ããã¾ãã â»ä»å使ã£ã¦ãsymfony2ã¯2.2ç³»ã§ãã2.1ã¨ãã ã¨åããã©ããã¯ãããã¾ããã ã¾ãã¯è«çåé¤ç¨ã®Doctrineã®æ¡å¼µãåå¾ãã https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/softdeleteable.md composer.jsonã®requireã®ä¸ã«ä»¥ä¸ã®ããã«è¨è¼ããã°composer installã§å ¥ããã¨æãã¾ãã ã¡ããã¨ãªã¼ããã¼ãã¼ã®è¨å®ããã¦
Symfony2ã§å°ãè¤éãªãã©ã¼ã ãä½ãéã®ã¡ã¢æ¸ãã ä¾ã¨ãã¦1ã¤ã®ååã¯è¤æ°ã®ã«ãã´ãªã«å±ããã è¦ä»¶ã¨ãã¦ã¯ç®¡çç»é¢ã®ååã®è¨å®ç»é¢ã«ã¦ãè¤æ°ã®ã«ãã´ãªãè¨å®ãããã¨ã¨ããã æ´ã«è¨å®ããã«ãã´ãªã«ã¯ã¤ãã§ã«ä½ãã¡ã¢æ¸ããè¨å®åºæ¥ããã¨ã¨ããã åEntityã¯ä»¥ä¸ã®ããã«å®è£ ããã Product.php (åå) <?php // ... class Product { /** * @var integer $id * * @ORM\Column(name="product_id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var string $productName * * @ORM\Column(n
ãã¹ã¶ ã½ã¼ã¹ã³ã¼ãã«æ°ããè¡ã1è¡è¿½å ãããã³ã«ãæ½å¨çã«æ°ãããã°ã追å ãã¦ããããããã¾ããã ãã¹ããèªååãã¦ãããã¨ã§ããã®ãããªãã°ãåé¿ã§ãã¾ãã ããã§ã¯ãSymfony2ã¢ããªã±ã¼ã·ã§ã³åãã«ã¦ããããã¹ãã¨ãã¡ã³ã¯ã·ã§ãã«ãã¹ããè¨è¿°ããæ¹æ³ã«ã¤ãã¦èª¬æãã¾ãã ãã¹ãã£ã³ã°ãã¬ã¼ã ã¯ã¼ã¯Â¶ Symfony2ã®ãã¹ãã¯ãPHPUnitã¨ãPHPUnitã§å¹ããã¦ãããã¹ããã©ã¯ãã£ã¹ãããã¤ãã®è¦ç´ã«å¤§ããä¾åãã¦ãã¾ãã ãããã«ã¤ãã¦ã¯è©³ãã解説ãã¾ããããã¾ã èªã¾ãã¦ããªãå ´åã¯ãPHPUnitã®ããã¥ã¡ã³ããèªãã§ãããã¨ããããããã¾ãã
ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãªãã·ã§ã³: app/config/config.yml ã¨ãã£ããã¡ã¤ã«ã§ã©ã®ãããªã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãªãã·ã§ã³ã使ããã®ã§ããããã ããã§ã¯ãSymfony2 ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ã§ä½¿ããã»ã¯ã·ã§ã³ã¨ãã¦å®ç¾©ããã¦ãããã¼(ãã¨ãã° framework)ãã¨ã«ãå©ç¨å¯è½ãªãã¹ã¦ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ã«ã¤ãã¦è§£èª¬ãã¾ãã framework doctrine security assetic swiftmailer twig monolog web_profiler ãã©ã¼ã ã¨ããªãã¼ã·ã§ã³ ãã©ã¼ã ãã£ã¼ã«ãã¿ã¤ããªãã¡ã¬ã³ã¹ ããªãã¼ã·ã§ã³å¶ç´ãªãã¡ã¬ã³ã¹ Twig ãã³ãã¬ã¼ãé¢æ°ãªãã¡ã¬ã³ã¹ ãã®ä» ãã®ãã¼ã¸ã®ç¿»è¨³ã¯ã¾ã è¡ããã¦ãã¾ããã Symfony2 ã®å®è¡ã«å¿ è¦ãªè¦ä»¶ ãã³ãã«Â¶ Symfony Standard Edition ã«ã¯ã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}