ãã®è¨äºã¯ãSymfony アドベントカレンダー2010 ã«åå ãã¦ãã¾ãã
- 日本Symfonyユーザー会
- Symfony アドベントカレンダー2010
- åã®è¨äºï¼2010-12-14 - jiskaのメモ書き
- 次ã®è¨äºï¼Redirect
æ稿æã®è¨å®ãééãã12/14ä»ãã«ãªã£ã¡ãã£ã¦ã¾ãããAdventã«ã¬ã³ãã¼15æ¥ç®ã®è¨äºã§ãï¼ï¼æ稿ã15æ¥æ©æã§ãï¼
æ¥ä»å¤ãã¡ããã¨URLå¤ã£ã¡ããã®ã§ãã®ã¾ã¾ã«ãã¦ããã¾ãããã容赦ãã ããã¾ãã
ã¨çºè¨ããã®ã§ãä»å㯠Doctrine MongoDB ODM ã Symfony2 ãã使ã£ã¦ã¿ããã¨ãããå²ã¨åå¿è
åããã¥ã¼ããªã¢ã«çãªè¨äºã§ãã
ä»å使ç¨ããç°å¢ã¯ä¸è¨ã®éãã
- PHP 5.3.3
- MongoDB 1.7.3
- Symfony2 PR4
- Doctrine MongoDB ODM 1.0.0 beta1
- PHP Mongo Extension 1.1.0 (pecl)
MongoDB ODM ã£ã¦ãªã«ï¼
ODM 㯠Object Document Mapper ã®äºã§ãDoctrine2 ã®ORMï¼Object Relational Mapperï¼ã«ããä¼¼ã¦ãã¦ãPHP 5.3.0+ ã®ãªãã¸ã§ã¯ããMongoDBã®ããã¥ã¡ã³ãï¼RDBã®ã¬ã³ã¼ãã«ç¸å½ï¼ã¨ãã¦ç°¡åã«æ±ããããã«ãªãã¾ãã
Symfony2 ãã MongoDB ODM ã¯æ¨æºã§ãµãã¼ãããã¦ããã®ã§ãæ©éãããã¦ã¿ããã¨æãã¾ãã
ä½ããã®
解説ã®ã¿ã ã¨ããã¥ã¡ã³ãè¦ãã»ããè±å¯ã ãããããã1åã®è¨äºã§ã¯è§£èª¬ããããªãã®ã§ãä»åã¯ãµã³ãã«ããã°ã©ã ã¨ãã¦âããããã¢ããªã±ã¼ã·ã§ã³âãä½ãäºã«ãã¾ãã
ã¾ããtwitterçãªä¸è¨æ²ç¤ºæ¿ã¢ããªã§ããã
è¦ä»¶ã¯ä¸è¨ã®éãã§ãã
- ããããã¢ããªã±ã¼ã·ã§ã³ã®æ©è½
- ããããæ稿
- ãããããªã¹ã表示ï¼ãããããæéé ï¼éé ï¼ã§è¡¨ç¤ºï¼
- ç¹å®ã®äººã®ãããã表示ï¼æå®ãã人ãçºè¨ãããããããæéé ï¼éé ï¼ã§è¡¨ç¤ºï¼
- ããããã¯ä»¥ä¸ã®é
ç®ã§æ§æããã¾ã
- ID (ä»å㯠MongoDB ã§èªåçæããã MongoId ãå©ç¨ãã¾ã)
- ååï¼Stringï¼ãå ¥åé ç®ã
- æ¬æï¼Stringï¼ãå ¥åé ç®ã
- ãããããæéï¼DateTimeï¼
ãµã³ãããã¯ã¹ãç¨æ
ä»åã¯ããµã³ãããã¯ã¹ããã¼ã¹ã«ä½ãã¾ãã®ã§ããµã³ãããã¯ã¹ãç¨æãã¾ãã
Gitãã¤ã³ã¹ãã¼ã«ãããLinuxç³»OSã§ããã°ãä¸è¨ã®ãããªæãã§ããããã
$ git clone git://github.com/symfony/symfony-sandbox.git $ cd symfony-sandbox/src $ ../bin/install_vendors.sh $ chmod 777 ../app/cache ../app/logs
ã¢ããªã±ã¼ã·ã§ã³è¨å®ã®å¤æ´
ã§ã¯ããã£ãããã¢ããªã±ã¼ã·ã§ã³ã®è¨å®ãå¤ãã¦ããã¾ãã
app/AppKernel.php
ã¾ãã¯ãMongoDB ODM ã使ãããã®ãã³ãã«ã¨ãããããã¢ããªã±ã¼ã·ã§ã³ç¨ã®ãã³ãã«ãã¢ããªã±ã¼ã·ã§ã³ã«ç»é²ããããã«ãAppKernel.phpãã¡ã¤ã«ãç·¨éãã¾ãã
<?php /* 8< 8< 8< 8< ç¥ 8< 8< 8< 8< */ class AppKernel extends Kernel { /* 8< 8< 8< 8< ç¥ 8< 8< 8< 8< */ public function registerBundles() { $bundles = array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), // enable third-party bundles new Symfony\Bundle\ZendBundle\ZendBundle(), new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), new Symfony\Bundle\DoctrineBundle\DoctrineBundle(), //new Symfony\Bundle\DoctrineMigrationsBundle\DoctrineMigrationsBundle(), new Symfony\Bundle\DoctrineMongoDBBundle\DoctrineMongoDBBundle(), // âã³ã¡ã³ãã¢ã¦ãã解é¤ããDoctrineMongoDBBundleãæå¹ã«ãã¾ãã // register your bundles new Application\SasayakiBundle\SasayakiBundle(), // âHelloBundleã¯ä½¿ããªãã®ã§ãHelloBundleãåé¤ãã // ãããã«SasayakiBundleãç»é²ãã¾ãã ); if ($this->isDebug()) { $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); } return $bundles; } /* 8< 8< 8< 8< ç¥ 8< 8< 8< 8< */
app/config/config.yml
次ã«ãè¨å®ãã¡ã¤ã«ã«MongoDB ODM ã®è¨å®ã追è¨ãã¾ãã
## doctrine_odm.mongodbãæå¹ã«ãªãããã«è¿½è¨ã doctrine_odm.mongodb: ~
ã¡ãªã¿ã«ãä¸è¨è¨å®ã®å ´åãæ¥ç¶ãªã©ã«ããã©ã«ãå¤ã使ããã¾ãã®ã§ãå¤æ´ãããå ´åã¯ãã©ã¡ã¼ã¿ãæå®ããå¿
è¦ãããã¾ãã
ä»åã¯ãä¸è¨ã®ããã«è¨å®ãã¾ããããç°å¢ã«åããã¦å¤æ´ãã¦ãã ããã
## doctrine_odm.mongodbãæå¹ã«ãªãããã«è¿½è¨ã doctrine_odm.mongodb: mappings: SasayakiBundle: ~ server: mongodb://localhost:27077 default_database: sasayakiapp options: connect: true persist: foobar
app/config/routing.yml
ã«ã¼ãã£ã³ã°ã«ã¼ã«ãå¤æ´ãã¾ãã
ä»åã¯ãSasayakiãã³ãã«ã®ã«ã¼ãã£ã³ã°ã«ã¼ã«ã«å¾ãããã«ãä¸è¨ã®ããã«å¤æ´ãã¾ããã
homepage: resource: SasayakiBundle/Resources/config/routing.yml
ãã®ä»ã®è¨å®
ãããããã©ã«ãã®HTMLãå¤ããããã°ãã好ã¿ã§ app/views/layout.twig ãç·¨éãã¾ãããã
Sasayakiãã³ãã«ã®ä½æ
ä¸æºåãæ´ã£ãããSasayakiãã³ãã«ãä½ãããã«ãã£ã¬ã¯ããªãä½ãã¾ãã
ãã£ã¬ã¯ããªã®æ§æã¯ä¸è¨ã®éãã§ãã
- src/Application/SasayakiBundle : Sasayakiãã³ãã«ã®ã«ã¼ã
- /Controller : ã³ã³ããã¼ã©ãã¡ã¤ã«
- /Document : ODMç¨ã®ã¯ã©ã¹ï¼ããã¥ã¡ã³ãï¼ãã¡ã¤ã«
- /Resources
- /config : è¨å®ãã¡ã¤ã«
- /views : ãã¥ã¼ãã¡ã¤ã«
src/Application/SasayakiBundle/SasayakiBundle.php
Sasayakiãã³ãã«ãæå¹ã«ããããã«ãBundleãã¡ã¤ã«ãæ¸ãã¾ãã
<?php namespace Application\SasayakiBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class SasayakiBundle extends Bundle { }
Sasayakiããã¥ã¡ã³ãã®ä½æ
ã¾ãã¯ãMongoDBã«ä¿åããããSasayakiããã¥ã¡ã³ãããä½ãã¾ãã
åºæ¬çã«ã¯ãä¸ã«æ¸ããããããã®æ å ±ããã®ã¾ã¾ã¯ã©ã¹åããã°OKã§ãããMongoDB ODM ã使ãããã«ã@mongodb:ãããå§ã¾ãã³ã¡ã³ããè¨è¿°ããå¿ è¦ãããã¾ãã
src/Application/SasayakiBundle/Document/Sasayaki.php
2010/12/15追è¨:
ä¸è¨ã®ãµã³ãã«ã§ã¯è¦ç´ ãpublicããããã£ã§å®£è¨ãã¦ãã¾ãããDoctrine2ã§ã¯ãprivate/protectedããããã£ã¨ãã¦å®£è¨ããä¸ã§ãgetter/setterã¡ã½ããã§ã¢ã¯ã»ã¹ããäºãæ¨å¥¨ããã¦ãã¾ãã
Doctrine2ããã¥ã¢ã«ï¼27. Best Practices — Doctrine 2 ORM 2 documentation
<?php namespace Application\SasayakiBundle\Document; /** * -- æ¥ç¶ããã³ã¬ã¯ã·ã§ã³åãæå® * @mongodb:Document(collection="sasayaki") * * -- nameã¨sasayaki_atãã¤ã³ããã¯ã¹ã¨ãã¦ç»é² * @mongodb:Indexes({ * @mongodb:Index(keys={"name"="asc"}), * @mongodb:Index(keys={"sasayaki_at"="desc"}) * }) */ class Sasayaki { /** * -- MongoIDå * ï¼MongoDBä¸ã§ã¯è¦å®ã®ãã©ã¤ããªãã¼ã§ãã * "_id" ãã£ã¼ã«ãã¨ãã¦ä¿åããã¾ãï¼ * @mongodb:Id */ protected $id; /** * @mongodb:String */ public $name; /** * @mongodb:String */ public $body; /** * -- MongoDateå (Timestamp) * @mongodb:Date */ protected $sasayaki_at; public function __construct() { // çææã«æéãèªåã§è¨å®ãããããã«ãã¾ãã // \DateTime ã使ãã®ããªã¹ã¹ã¡ã $this->sasayaki_at = new \DateTime(); } /** * return integer $id */ public function getId() { return $this->id; } /** * return DateTime $sasayaki_at */ public function getSasayakiAt() { return $this->sasayaki_at; } }
id 㨠sasayaki_at ã«ã¤ãã¦ã¯ãèªåçã«çæãããå¤æ´ä¸å¯ãªã®ã§ protected ã¡ã³ãå¤æ°ã¨ãã¦å®ç¾©ããgetXXXã¨ããã¡ã½ããã使ç¨ãã¦ã¢ã¯ã»ã¹ããäºã¨ãã¾ãã
ãªããé常ã®ã¿ã¤ã ã¹ã¿ã³ãã®ä¿åã«ã¯ã@mongodb:Dateããæå®ãã¾ãã
ã@mongodb:Timestampãã§ã¯ããã¾ããã®ã§ã注æãã¦ãã ãããã@mongodb:Timestampãã§å®ç¾©ããå ´åãMongoTimestampã¯ã©ã¹ãå©ç¨ããããã®ã¯ã©ã¹ã¯ã·ã£ã¼ãã£ã³ã°ã§ä½¿ç¨ãããç¹å¥ãªåã¨ãªãã¾ãã
MongoTimestampã¯ã©ã¹ã«ã¤ãã¦ã¯ãPHP: MongoTimestamp - Manualãåç
§ãã¦ãã ããã
注æï¼
ODMã¸ã®Indexé¢é£ã®è¨å®ã¯ãä¸è¨è¨å®ã§éã£ã¦ãããããªã®ã§ãããMongoDBå´ã«ã¡ããã¨ä¼ãã£ã¦ããªã模æ§ã§ãã
ãªããã¯è¯ãåãã£ã¦ããªãï¼ãã¡ãã¨èª¿ã¹ã¦ããªãï¼ã®ã§ãããæ å ±ããæã¡ã®æ¹ãããã°æãã¦ãã ãããããODMå´ã§ã®ã¤ã³ããã¯ã¹æ å ±ã®ãã§ãã¯
<?php // MongoDB ODM DocumentManager ãåå¾</span> $dm = $this->get('doctrine.odm.mongodb.document_manager'); // ã¤ã³ããã¯ã¹æ å ±ãåå¾ var_export($dm->getClassMetadata('Application\SasayakiBundle\Document\Sasayaki')->getIndexes());è¿ã£ã¦ããå¤ï¼nameã¨sasayaki_atããããããã¼æå®ããã¦ããï¼
<?php array( array( 'keys' => array('name' => 1), 'options' => array('unique' => false), ), array( 'keys' => array('sasayaki_at' => -1), 'options' => array('unique' => false), ), )MongoDBå´ã§ã®ã¤ã³ããã¯ã¹æ å ±ã®ãã§ãã¯ï¼Mongoã·ã§ã«ï¼
> db.sasayaki.getIndexes();è¿ã£ã¦ããå¤ï¼_idãããã¼ã«ãªã£ã¦ããªãï¼
[{ "name" : "_id_", "ns" : "sasayakiapp.sasayaki", "key" : { "_id" : 1 }, "v" : 0 }]ãªãããï¼ï¼
2011-01-04追è¨
èªåçã«ãã£ã¦ããããã®ã¨åéããã¦ããã®ã§ããã
ä¸è¨ã®ããã«æ示çã«ã¤ã³ããã¯ã¹ãä½ããªãã¨ãããªãããã§ãã<?php $dm->getSchemaManager()->ensureIndexes();ã¿ã¤ãã³ã°çã«ã¯ããã¼ã¿æå ¥æã®flush()ã®åããããã¨æããã¾ãã
ã³ã³ããã¼ã©ã®ä½æ
MongoDB ODMã®å©ç¨æ¹æ³
ãã£ãä½ã£ãããã¥ã¡ã³ãã使ãã®ã§ãããããã
<?php use Application\SasayakiBundle\Document\Sasayaki;
ãªã©ã¨ãã¦ããã¾ãã
ã¾ããã³ã³ããã¼ã©å ã§ä¸è¨ã®ããã«MongoDB ODM ã® DocumentManager ãåå¾ãã¦ããã¾ãã
<?php // MongoDB ODM DocumentManager ãåå¾ $dm = $this->get('doctrine.odm.mongodb.document_manager');
MongoDB ã¸ãã¼ã¿ãä¿åããã«ã¯ãDocumentManager ãåå¾ããå¾ã«ä¸è¨ã®ããã«ãã¾ãã
<?php // Sasayakiããã¥ã¡ã³ããçæãããã¼ã¿ãå ¥ãã $sasayaki = new Sasayaki(); $sasayaki->name = 'ååã§ã'; $sasayaki->body = 'ããã«ããã£ããã¹ããæå®ãã¾ãï¼'; $dm->persist($sasayaki); // ãã¼ã¿ãå ¥ã㦠$dm->flush(); // ä¿å
ãã¼ã¿ã®åå¾ã¯æ¹æ³ãä½éããããã¾ãã
<?php // 1. å ¨ä»¶åå¾ $sasayaki = $dm->find('Application\SasayakiBundle\Document\Sasayaki') ->getResults(); // 2. _idãæå®ãã1件ã ãåå¾ $sasayaki = $dm->findOne('Application\SasayakiBundle\Document\Sasayaki', array("_id" => new \MongoId("XXXXXXXXXXXXXXXXXXXXXXXX")) ); // 3. ãªãã¸ããªãåå¾ããnameãJhonã®ãã®ãåå¾ $sasayaki = $dm->getRepository('Application\SasayakiBundle\Document\Sasayaki') ->findByName("Jhon") ->getResults(); // 4. createQuery ã§ã¯ã¨ãªãçæããsasayaki_atãéé ã§åå¾ $sasayaki = $dm->createQuery('Application\SasayakiBundle\Document\Sasayaki') ->sort('sasayaki_at', 'desc') ->getResult();
ãªã©ã®æ¹æ³ã§åå¾åºæ¥ã¾ãã
ã¡ãªã¿ã«ãä»åã¯ä½¿ãã¾ããããfindAndModify ã使ç¨ããäºã§å¹ççã«ç·¨éã»åé¤ãè¡ããã¨ãå¯è½ã§ãã
<?php $sasayaki = $dm->createQuery('Application\SasayakiBundle\Document\Sasayaki') // ãããããæ¢ã ->findAndModify() ->field('name')->equals('Jhon') // ã¢ãããã¼ããã¾ã ->update() ->field('name')->set('ã¸ã§ã³') ->execute(); $sasayaki = $dm->createQuery('Application\SasayakiBundle\Document\Sasayaki') // ãããããæ¢ã ->findAndModify() ->field('name')->equals('Jhon') // åé¤ãã ->remove() ->execute();
src/Application/SasayakiBundle/Controller/SasayakiController.php
ã§ã¯ãçµæã¨ãã¦åºæ¥ãã³ã³ããã¼ã©ã¯ä¸è¨ã®éãã§ãã
<?php namespace Application\SasayakiBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Form; use Symfony\Component\Form\TextField; use Symfony\Component\Form\TextareaField; // ãã£ãä½ã£ãSasayakiããã¥ã¡ã³ãã使ã use Application\SasayakiBundle\Document\Sasayaki; class SasayakiController extends Controller { /** * ããããã®åå¾ */ public function listAction() { // MongoDB ODM DocumentManager ãåå¾ $dm = $this->get('doctrine.odm.mongodb.document_manager'); // Sasayakiããã¥ã¡ã³ãã®ã¯ã¨ãªãä½æ $sasayaki = $dm->createQuery('Application\SasayakiBundle\Document\Sasayaki') // çºè¨é ï¼éé ï¼ã«ã½ã¼ã ->sort('sasayaki_at', 'desc') // æåã®10件ã ã ->limit(10) // åå¾ ->getResult(); return $this->render('SasayakiBundle:Sasayaki:index.twig', array( 'sasayaki' => $sasayaki, 'sasayakiname' => 'ã¿ããª', )); } /** * $nameã®ãããããåå¾ */ public function findByNameAction($name) { // MongoDB ODM DocumentManager ãåå¾ $dm = $this->get('doctrine.odm.mongodb.document_manager'); // Sasayakiããã¥ã¡ã³ãã®ã¯ã¨ãªãä½æ $sasayaki = $dm->createQuery('Application\SasayakiBundle\Document\Sasayaki') // ãã£ã¼ã«ã name ã $name ã®ããã¥ã¡ã³ãã ->field('name')->equals($name) // çºè¨é ï¼éé ï¼ã«ã½ã¼ã ->sort('sasayaki_at', 'desc') // æåã®10件ã ã ->limit(10) // åå¾ ->getResult(); return $this->render('SasayakiBundle:Sasayaki:index.twig', array( 'sasayaki' => $sasayaki, 'sasayakiname' => $name, )); } /** * ããããã®æ稿 * ã¢ã¼ãåæ¿ã®ããã« $standalone ãå®ç¾©ãã¦ããï¼viewã§ä½¿ç¨ï¼ */ public function createAction($standalone = true) { // Sasayakiããã¥ã¡ã³ããçæ $sasayaki = new Sasayaki(); // ãã©ã¼ã ã¨çµã³ã¤ã㦠$form = new Form('sasayaki', $sasayaki, $this->get('validator')); // å ¥åé ç®ã追å $form->add(new TextField('name')); $form->add(new TextareaField('body')); // ã¡ã½ããã POST ã®å ´å if ('POST' === $this->get('request')->getMethod()) { // éä¿¡ããã sasayaki ãåå¾ã㦠$form->bind($this->get('request')->request->get('sasayaki')); // ããªãã¼ã·ã§ã³OKãªã if ($form->isValid()) { // MongoDB ODM DocumentManager ãåå¾ $dm = $this->get('doctrine.odm.mongodb.document_manager'); // DocumentManager ã«ãã¼ã¿ãå ¥ã㦠$dm->persist($form->getData()); // ä¿å $dm->flush(); // ãªã¹ããã¼ã¸ã«ãªãã¤ã¬ã¯ã return $this->redirect($this->generateUrl('sasayaki_list')); } } return $this->render('SasayakiBundle:Sasayaki:sasayakiform.twig', array( 'form' => $form, 'standalone' => $standalone, )); } }
src/Application/SasayakiBundle/Resources/config/routing.yml
ã§ã¯ããã®ã³ã³ããã¼ã©ã«ã¢ã¯ã»ã¹åºæ¥ãããã«ã«ã¼ãã£ã³ã°ãæ¸ãã¾ãã
sasayaki_list: pattern: / defaults: { _controller: SasayakiBundle:Sasayaki:list } sasayaki_create: pattern: /sasayaku defaults: { _controller: SasayakiBundle:Sasayaki:create } sasayaki_byname: pattern: /name/:name defaults: { _controller: SasayakiBundle:Sasayaki:findByName }
ããã§ãhttp://example.com/ ã§ä¸è¦§ãhttp://example.com/sasayaku ã§æ稿ç»é¢ãhttp://example.com/name/[æ¤ç´¢ããåå] ã§ç¹å®ã®äººã®æ稿ç»é¢ãè¦ããã¾ããã
src/Application/SasayakiBundle/Resources/config/config.yml
Validationãæå¹ã«ãªãããã«config.ymlãæ¸ãã¾ãã
app.config: validation: enabled: true
src/Application/SasayakiBundle/Resources/config/validation.yml
æä½éã®Validationã®è¨å®ãæ¸ãã¾ããã
Application\SasayakiBundle\Document\Sasayaki: properties: name: - NotBlank: ~ body: - NotBlank: ~
ãã¥ã¼ã®ä½æ
ããã¾ã§ããã°ãå¾ã¯ãã¥ã¼ã®ä½æã®ã¿ã
ãµã³ãã«ãªã®ã§ãæä½éã®å
容ãæ¸ãã¦ããã¾ãã
src/Application/SasayakiBundle/Resources/views/layout.twig
{% extends "::layout.twig" %} {% block body %} {% block content %}{% endblock %} {% endblock %}
src/Application/SasayakiBundle/Resources/views/Sasayaki/index.twig
ãªã¹ããã¼ã¸ã®ãã³ãã¬ã¼ãã§ãã
{% extends "SasayakiBundle::layout.twig" %} {% block content %} {# <!-- ä¸è¦§ãã¼ã¸ã«ãæ稿ç»é¢ã欲ããã®ã§ãcreateActionã®å 容ãæç»ãã¾ãã ãã®ãã©ã¼ã ã¯ããªã¹ããã¼ã¸ã«çµã¿è¾¼ã¾ããããã standaloneãã©ã°ãfalseã«ãã¦ããã¾ãã --> #} {% render "SasayakiBundle:Sasayaki:create" with ['standalone': false] %} {# <!-- ç¹å®ã®äººã®ããããã®è¡¨ç¤ºã®å ´åãsasayakinameã«äººã®ååãå ¥ãã¾ã --> #} <h2>{{ sasayakiname|default('ã¿ããª') }} ã®ãããã</h2> <div id="list"> {% for item in sasayaki %} {# <!-- ããããã®ããããã表示 --> #} <div class="sasayaki"> <div class="name">name: <a href="{% path 'sasayaki_byname' with ['name': item.name] %}">{{ item.name }}</a></div> <div class="body">{{ item.body }}</div> <div class="date">sasayaki at: {{ item.sasayakiAt|date("Y-m-d H:i:s") }}</div> </div> {% endfor %} </div> {% endblock %}
src/Application/SasayakiBundle/Resources/views/Sasayaki/sasayakiform.twig
{# <!-- standalone ã trueï¼SasayakiBundle:Sasayaki:create ã«ç´æ¥ã¢ã¯ã»ã¹ï¼ã®å ´åã é常ã®ã¬ã¤ã¢ã¦ããç¶æ¿ãã ãã以å¤ã®ï¼ãªã¹ããã¼ã¸ããå¼ã³åºãããï¼å ´åãform.twig ã ç¶æ¿ãã¾ãã --> #} {% extends standalone ? "SasayakiBundle::layout.twig" : "SasayakiBundle:Sasayaki:form.twig" %} {% block content %} <div id="sasayakiForm"> <h2>ãããã</h2> <form action="{% path 'sasayaki_create' %}" method="post"> {{ form|render }} <input type="submit" value="Send!" /> </form> </div> {% endblock %}
src/Application/SasayakiBundle/Resources/views/Sasayaki/form.twig
{# ãã©ã¼ã 以å¤ã«ã¯æç»ããªã #} {% block content %} {% endblock %}
å®æï¼
ã¨ããããã§ãå®æããããããã¢ããªã±ã¼ã·ã§ã³ã¯ä¸è¨ã®ãããªãã®ã«ãªãã¾ããã
â ç¹å®ã®äººã®ä¸è¦§ç»é¢
ãã
Symfony2 ã®ä¸æºåããå§ãããããè¥å¹²é·ããªã£ã¦ãã¾ãã¾ããããMongoDB ODMã¸ã®ã¢ã¯ã»ã¹èªä½ã¯é常ã«ç°¡åã§ãæè»ãªã¢ã¯ã»ã¹ãå¯è½ã«ãªã£ã¦ãããã¨ãåãããã¨æãã¾ãã
MongoDB ODM ã®æ©è½ã¯ãããã§ã¯å°åºæ¸ãã¤ãããªãã»ã©å¤ãããã¾ãã®ã§ããã² MongoDB ODM ã触ã£ã¦ããã ãããã¨æãã¾ãã
MongoDBãSymfony2ã楽ãããï¼
ãããã£ãããããï¼ã¨ãããããããªãï¼ã¨ãããããã£ãããã³ããããã¾ããããæ¯éã @madapaja ãããã¯ãã³ã¡ã³ãã§æãã¦ãã ããï¼
Symfony Advent 2010
Symfony Advent 2010ã§ã¯12æ1æ¥ãã12æ24æ¥ã¾ã§ã使ã£ã¦æ¥æ¿ããã§symfonyã§ã¤ã¤ãªã¨æã£ãå°ããªtipsããå é¨æ§é ã¾ã§è¿«ã£ã解説ãªã©ãããã°è¨äºã«ãã¦å ¬éãã¦ããã¤ãã³ãã§ãã
日本Symfonyユーザー会
Symfony アドベントカレンダー2010
â»Syfony Advent 2010ã¯symfony好ããªæå¿ã§éã¾ã£ããã¼ã ã§ãã