Symfonyã«ææ¦09ãJobeet 2æ¥ç®ã3æ¥ç®ã
Jobeet2æ¥ç®ã
ããã§ã¯ã©ããªããã°ã©ã ãä½ãã®ãã決ãã¦ããã ãã®ããã ãææ¸ãã®ç»é¢ãããããã
Jobeetã使ã人
ä»ããä½ããµã¤ããã©ããªäººã使ãã®ããæ³å®ã
- 管çè (admin)ï¼
- ã¦ã¼ã¶ã¼(user)ï¼
- æ稿è (poster)ï¼
- ã¢ãã£ãªã¨ã¤ã(affiliate)ï¼
Jobeetã®ã¦ã¼ã¶ã¼ã¹ãã¼ãªã¼
ãµã¤ãã使ã人ãã©ããªæ©è½ãæ±ãã¦ããã®ãæ³å®ã
ããã³ãã¨ã³ãï¼frontendï¼ã®æ©è½
- ãã¼ã ãã¼ã¸ä¸ã§ã¦ã¼ã¶ã¼ã¯ææ°ã®æå¹ãªç¶æ ã®ä»äºãè¦ãã¾ã
- ã¦ã¼ã¶ã¼ã¯ã«ãã´ãªã¼ã«å±ããå ¨ã¦ã®ä»äºãè¦ããã¨ãã§ãã¾ã
- ã¦ã¼ã¶ã¼ã¯ãã¼ã¯ã¼ãã§ä»äºã®ãªã¹ããçµãè¾¼ãã¾ã
- ã¦ã¼ã¶ã¼ã¯ä»äºãã¯ãªãã¯ãããã¨ã§è©³ç´°ãªæ å ±ãè¦ããã¨ãã§ãã¾ã
- ã¦ã¼ã¶ã¼ã¯ä»äºãæ²è¼ã§ãã¾ã
- ã¦ã¼ã¶ã¼ãã¢ãã£ãªã¨ã¤ãã®ç³ãè¾¼ã¿ããã
- ã¢ãã£ãªã¨ã¤ãããã人ã¯ç¾å¨ã®æå¹ãªä»äºã®ãªã¹ããåå¾ã§ãã¾ã
ããã¯ã¨ã³ãï¼backendï¼ã®æ©è½
- 管çè ã¯Webãµã¤ããè¨å®ãã¾ã
- 管çè ã¯ä»äºã管çãã¾ã
- 管çè ã¯ã¢ãã£ãªã¨ã¤ãã¦ã¼ã¶ã¼ã管çãã¾ã
ã©ãããæ±äººåéã®æ²ç¤ºæ¿ãµã¤ãã®ããã ã
Jobeet3æ¥ç®ã
ãã¼ã¿ã¢ãã«ãããã§ã¯Jobeetç¨ã®ãã¼ã¿ãã¼ã¹ãä½ãã
Symfonyã§ã¯config/schema.ymlã¨ãããã¡ã¤ã«ã«ãã¼ã¿ãã¼ã¹ã®ãã¼ãã«åãã«ã©ã ãªã©ã®æ
å ±ãè¨å
¥ãã¦ãã³ãã³ãã©ã¤ã³ããSymfonyã³ãã³ããå®è¡ãã¦ããã¨ãèªåã§ãã¼ã¿ãã¼ã¹ãããã¼ã¿ãã¼ã¹æ¥ç¶ç¨ã®ããã°ã©ã ãããä½ã£ã¦ããããããã
æ©éãã£ã¦ã¿ãã訳ã®ããããªãã¨ããã¯èªã¿é£ã°ããªãããã£ã¦ã¿ãã
â /jobeet/config/schema.ymlãã¡ã¤ã«ã«ãããã¹ãã¨ãã£ã¿ã§éããä¸è¨ã³ããã
# config/schema.yml propel: jobeet_category: id: ~ name: { type: varchar(255), required: true, index: unique } jobeet_job: id: ~ category_id: { type: integer, foreignTable: jobeet_category, foreignReference: id, required: true } type: { type: varchar(255) } company: { type: varchar(255), required: true } logo: { type: varchar(255) } url: { type: varchar(255) } position: { type: varchar(255), required: true } location: { type: varchar(255), required: true } description: { type: longvarchar, required: true } how_to_apply: { type: longvarchar, required: true } token: { type: varchar(255), required: true, index: unique } is_public: { type: boolean, required: true, default: 1 } is_activated: { type: boolean, required: true, default: 0 } email: { type: varchar(255), required: true } expires_at: { type: timestamp, required: true } created_at: ~ updated_at: ~ jobeet_affiliate: id: ~ url: { type: varchar(255), required: true } email: { type: varchar(255), required: true, index: unique } token: { type: varchar(255), required: true } is_active: { type: boolean, required: true, default: 0 } created_at: ~ jobeet_category_affiliate: category_id: { type: integer, foreignTable: jobeet_category, foreignReference: id, required: true, primaryKey: true, onDelete: cascade } affiliate_id: { type: integer, foreignTable: jobeet_affiliate, foreignReference: id, required: true, primaryKey: true, onDelete: cascade }
â
ã¿ã¼ããã«ã§mysqladminã³ãã³ãã使ããããã«ãã¦ãjobeetã¨è¨ãååã®ãã¼ã¿ãã¼ã¹ä½æã
Mac:~ kaneda$ sudo ln -s /Applications/xampp/xamppfiles/bin/mysqladmin /usr/local/bin/mysqladmin Mac:~ kaneda$ mysqladmin -uroot -p create jobeet Enter password: ï¼MySQLã®ãã¹ã¯ã¼ãï¼ Mac:~ kaneda$
http://localhost/phpmyadminã§ä½ã£ã¦ãããã
â 次ã«/jobeet/config/schema.ymlã§æ¸ããè¨å®ãjobeetãã¼ã¿ãã¼ã¹ã«ã¤ã£ããã
Mac:~ kaneda$ cd ~/Sites/jobeet Mac:jobeet kaneda$ php symfony configure:database "mysql:host=localhost;dbname=jobeet" root ï¼MySQLã®ãã¹ã¯ã¼ãï¼ Mac:jobeet kaneda$ php symfony propel:build-sql Mac:jobeet kaneda$ php symfony propel:insert-sql Execution of target "insert-sql" failed for the following reason: /Applications/xampp/xamppfiles/lib/php/pear/symfony/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml:275:1: [wrapped: could not find driver] [phing] /Applications/xampp/xamppfiles/lib/php/pear/symfony/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml:275:1: [wrapped: could not find driver] Some problems occurred when executing the task: build-propel.xml:275:1: [wrapped: could not find driver] If the exception message is not clear enough, read the output of the task for more information
ã²ã©ãè²ã®ã¨ã©ã¼ãã§ãããã®ã¨ã©ã¼ã§ããªãæ©ãã ãã©ãä¸ã®ããã«phpã®å ´æãæå®ãã¦ãããã¨ãµã¯ãã¨ãããã
Mac:jobeet kaneda$ /Applications/xampp/xamppfiles/bin/php symfony propel:insert-sql
ã·ã§ã¼ãã«ããã®ä½ãæ¹ãæªãã£ãã®ããã©ãããpdo_mysqlã¨ããã¢ã¸ã¥ã¼ã«ãphpããã°ã©ã ããèªã¿è¾¼ããªããã¨ãåå ããããã§ãåºæ¥ãã®ã§ããã§ããã
â 次ã¯ãã¼ã¿ãã¼ã¹ã¨ããã¨ãããããã®PHPãã¡ã¤ã«ãçæããããã®ã³ãã³ãã
Mac:jobeet kaneda$ php symfony propel:build-model
/jobeet/lib/model/ãã©ã«ãã«ãããããã¡ã¤ã«ãåºæ¥ãã
â ã¨ããããããã¾ã§ã®æµããããã°ã©ã ã§ãã¼ã¿ãã¼ã¹ã使ãå ´åã®åæããã»ã¹ãããã
- schema.ymlãã¡ã¤ã«ã«ã©ããªãã¼ã¿ãã¼ã¹ã«ããã®ããæ¸ãã¦
- ãã¼ã¿ãã¼ã¹ãä½ãã
- propel:build-sqlã§ãã¼ã¿ãã¼ã¹ç¨ã®sqlãã¡ã¤ã«ãä½ãã
- insert-sqlã§ãã¼ã¿ãã¼ã¹ã«schema.ymlã§æ¸ããã®ãã¼ãã«ãä½ãã
- build-modelã§ãã¼ã¿ãã¼ã¹ã¨ããã¨ãããããã®PHPãã¡ã¤ã«ãçæããã
â
ã¡ãªã¿ã«ä¸ã®3ã5ã¯ä¸è¨ã³ãã³ãã§ä¸æ°ã«ãã£ã¦ãããã
Mac:jobeet kaneda$ php symfony propel:build-all --no-confirmation
â
ããã¦ãã£ãã·ã¥ãåé¤ã
Mac:jobeet kaneda$ php symfony cc
â
åæãã¼ã¿ç¨ã®YMLä½æ
/jobeet/data/fixtures/010_categories.ymlã¨ãããã¡ã¤ã«ãä½ããä¸è¨ã³ãã
JobeetCategory: design: { name: Design } programming: { name: Programming } manager: { name: Manager } administrator: { name: Administrator }
次ã«/jobeet/data/fixtures/020_jobs.ymlã¨ãããã¡ã¤ã«ãä½ããä¸è¨ã³ãã
JobeetJob: job_sensio_labs: category_id: programming type: full-time company: Sensio Labs logo: sensio-labs.gif url: http://www.sensiolabs.com/ position: Web Developer location: Paris, France description: | You've already developed websites with symfony and you want to work with Open-Source technologies. You have a minimum of 3 years experience in web development with PHP or Java and you wish to participate to development of Web 2.0 sites using the best frameworks available. how_to_apply: | Send your resume to fabien.potencier [at] sensio.com is_public: true is_activated: true token: job_sensio_labs email: [email protected] expires_at: 2010-10-10 job_extreme_sensio: category_id: design type: part-time company: Extreme Sensio logo: extreme-sensio.gif url: http://www.extreme-sensio.com/ position: Web Designer location: Paris, France description: | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in. Voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. how_to_apply: | Send your resume to fabien.potencier [at] sensio.com is_public: true is_activated: true token: job_extreme_sensio email: [email protected] expires_at: 2010-10-10
ãã¡ã¤ã«ãäºã¤ã«åããã¦ãããã©ã1ã¤ã«ã¾ã¨ãããã¨ãã§ããããã ã
ãã¡ã¤ã«åã®å
é ã®æ°åã¯ããã®ãã¡ã¤ã«ãèªã¿è¾¼ãé çªã
â
ç»åãã¡ã¤ã«ãæ¾ã£ã¦ãã
ä¸ã®ç»åããã¦ã³ãã¼ããã¦/jobeet/web/uploads/ã®ä¸ã«jobsãã©ã«ããä½æãããã®ä¸ã«ç»åãã¶ã¡è¾¼ãã
http://www.symfony-project.org/get/jobeet/sensio-labs.gif
http://www.symfony-project.org/get/jobeet/extreme-sensio.gif
â
ãã¼ã¿ãã¼ã¹ã«åæãã¼ã¿ãæå
¥
ãã¼ã¿ãã¼ã¹ã«ã¢ã¯ã»ã¹ããå ´åã®ã³ãã³ãã¯PHPã®ãã¹ããã«ãã¹ã§ã
Mac:jobeet kaneda$ /Applications/xampp/xamppfiles/bin/php symfony propel:data-load
http://localhost/phpmyadminã§ç¢ºèªããã¨ç¡äºãã¼ã¿ãå ¥ã£ã¦ããã
â
ã¢ã¸ã¥ã¼ã«ãä½ã
jobãªã¹ãã®è¡¨ç¤ºãjobãç·¨éããç»é¢ãjobãåé¤ããæ©è½ãªã©ã®ã¢ã¯ã·ã§ã³ãèªåã§ä½ã£ã¦ãããéæ³ã®ã³ãã³ãã ã£ã
Mac:jobeet kaneda$ php symfony propel:generate-module --with-show --non-verbose-templates frontend job JobeetJob [?php include_stylesheets_for_form($form) ?] [?php include_javascripts_for_form($form) ?] Fatal error: Class 'JobeetJobForm' not found in /Applications/xampp/xamppfiles/lib/php/pear/symfony/generator/sfModelGenerator.class.php on line 321
ãããå¤ãªã¨ã©ã¼ãã調ã¹ãã¨ããããã©ã¼ã ã®ãªã«ããç¡ãã¨è¨ã£ã¦ãããããã®ã§ãä¸è¨ã³ãã³ãã§ãã©ã¼ã é¨åã®ãã¡ã¤ã«ãçæããã³ãã³ããå®è¡ãã¦ãããã¨ãã¾ããã£ãã
Mac:jobeet kaneda$ php symfony propel:build-forms âããã¦ããä¸åã¢ã¸ã¥ã¼ã«ä½æ Mac:jobeet kaneda$ php symfony propel:generate-module --with-show --non-verbose-templates frontend job JobeetJob âãã£ãã·ã¥åé¤ Mac:jobeet kaneda$ php symfony cc
/jobeet/apps/modules/ã«jobã¨ãããã©ã«ããåºæ¥ã¦ããããããã¡ã¤ã«ãçæãããã
ããã¦ãhttp://jobeet.local/frontend_dev.php/jobã«ã¢ã¯ã»ã¹ã
ã¬ã¤ã¢ã¦ããå¤ã ãã©ã020_jobs.ymlã«æ¸ããåæãã¼ã¿ã表示ããã¦ãããããããç·¨éç»é¢ï¼http://jobeet.local/frontend_dev.php/job/edit/id/1ï¼ã表示ãã¦ã¿ãã¨ã
500 | Internal Server Error | RuntimeException Class "JobeetCategory" must implement a "__toString" method to be rendered in a "sfWidgetFormPropelChoice" widget ã
ã¾ããã¦ãã¨ã©ã¼ããããªãé²ãã§ãããªãã
調ã¹ã¦ã¿ãã¨ããããã®ãã¥ã¼ããªã¢ã«ã®èª¬æé åºãééã£ã¦ããããããå
ã«ããã°ã©ã ãç·¨éããã¹ãããããã£ã¦ãããªãã¨ã¨ã©ã¼ãã§ããã®ãããã
/jobeet/lib/model/JobeetCategory.phpãéãã¦ãä¸è¨ã®éãç·¨éã
<?php class JobeetCategory extends BaseJobeetCategory { public function __toString() { return $this->getName(); } }
次ã«/jobeet/lib/model/JobeetJob.phpãéãã¦ãä¸è¨ã®éãç·¨éã
<?php class JobeetJob extends BaseJobeetJob { public function __toString() { return sprintf('%s at %s (%s)', $this->getPosition(), $this->getCompany(), $this->getLocation()); } }
æå¾ã«/jobeet/lib/model/JobeetAffiliate.phpãéãã¦ãä¸è¨ã®éãç·¨éã
<?php class JobeetAffiliate extends BaseJobeetAffiliate { public function __toString() { return $this->getUrl(); } }
å度編éç»é¢ã«ã¢ã¯ã»ã¹ã
http://jobeet.local/frontend_dev.php/job/edit/id/1
ãã¥ã¼ããªã¢ã«ã®éãã¡ããã¨è¡¨ç¤ºãããã