Zend Framework Study@Tokyo #2

  • 2,302 views
Uploaded on

Zend Framework Study@Tokyo#2

Zend Framework Study@Tokyo#2

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,302
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
23
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

























































Transcript

  • 1. 2010/03/06 id:heavenshell
  • 2. wozozo …
  • 3. id:heavenshell (3/6 ) http://d.hatena.ne.jp/heavenshell http://twitter.com/heavenshell http://github.com/heavenshell http://openpear.org/maintainer/heavenshell Java (Cubby ) Python, JavaScript, Vim
  • 4. 2007 ( ) (PEAR::Pager ) → Phwittr Ver1.5 Ver1.8 Zend_Application
  • 5. Zend_Application (2009/10) 1.10
  • 6. Zend_Application (2009/10) 1.10
  • 7. Doctrine Doctrine Doctrine … ←
  • 8. ASP ( ) CRUD cron (JavaScript) API
  • 9. Zend Framework 1.9x http://github.com/heavenshell/gene Zend_Db, Revulo_View_Phtmlc Doctrine Twig Github web-app-theme http://github.com/pilu/web-app-theme
  • 10. app |-- Gene.php |-- config |-- layouts | |-- admin | `-- index |-- locales | `-- ja |-- models | |-- Tables | `-- Tables.php |-- modules | |-- admin | |-- api | `-- index |-- plugins | `-- Gene |-- services `-- views `-- scripts
  • 11. app |-- Gene.php |-- config |-- layouts | |-- admin | `-- index |-- locales | `-- ja |-- models Zend_Db ( Dao) | |-- Tables | `-- Tables.php |-- modules | |-- admin | |-- api | `-- index |-- plugins | `-- Gene |-- services `-- views `-- scripts
  • 12. app |-- Gene.php |-- config |-- layouts | |-- admin | `-- index |-- locales | `-- ja |-- models Zend_Db ( Dao) | |-- Tables | `-- Tables.php |-- modules Zend_Controller | |-- admin | |-- api | `-- index |-- plugins | `-- Gene |-- services `-- views `-- scripts
  • 13. app |-- Gene.php |-- config |-- layouts | |-- admin | `-- index |-- locales | `-- ja |-- models Zend_Db ( Dao) | |-- Tables | `-- Tables.php |-- modules Zend_Controller | |-- admin | |-- api | `-- index |-- plugins | `-- Gene ( ) |-- services `-- views `-- scripts
  • 14. app |-- Gene.php |-- config |-- layouts | |-- admin | `-- index |-- locales | `-- ja |-- models Zend_Db ( Dao) | |-- Tables | `-- Tables.php |-- modules Zend_Controller | |-- admin | |-- api | `-- index |-- plugins | `-- Gene ( ) |-- services `-- views `-- scripts
  • 15. modules application
  • 16. Plugin Zend_Controller_Plugin_Abstract ( ) CSRF ○○
  • 17. Zend_Auth::getInstance()->getIdentity();
  • 18. Q4M Openpear::Net_Q4M … Zend_Queue Zend_Queue_Adapter_Q4m
  • 19. 1.7x Zend Framework use-at-will DB, View, Session, Routing, etc
  • 20. 1.8 Zend_Application Dependency Injection noopable 1.7
  • 21. Storefront (http://www.thepopeisdead.com/) Zend_Application zfdebugdoctrine (http://github.com/danceric/zfdebugdoctrine) ZFDebug Doctrine
  • 22. Magento (http://www.magentocommerce.com/) OSS EC Live Commerce (http://www.live-commerce.com/) OSS TomatoCMS (http://tomatocms.com/) OSS CMS
  • 23. Zend_Application_Bootstrap_Bootstrap application.ini ini application/ Bootstrap.php
  • 24. Zend_Application_Bootstrap_Bootstrap [application.ini] bootstrap.path = GENE_LIB_PATH "/Bootstrap.php" bootstrap.class = "Gene_Bootstrap" application.ini ↓ ini bootstrap.path = GENE_APP_PATH "/Phwitter.php" application/ bootstrap.class = "Phwittr" Bootstrap.php
  • 25. ( junichiro ) Zend_Db, Doctrine ( Zend_Db) View (ry Zend_Log Zend_Cache
  • 26.
  • 27. Validation Zend_Filter_Input (Zend_Form ) Zend_Translate
  • 28. FW ini Zend_Translate
  • 29. $requests = array('name' => 'hogehogehoge'); $validations = array( 'name' => array( new Zend_Validate_StringLength(1, 10, 'utf-8'), 'messages' => array( 0 => $translate->_('User name should enter less than 100.'), ) ) ); $validator = new Zend_Filter_Input(null, $validation); $valid = $validator->setData($requests)->isValid(); var_dump($input->getInvalid());
  • 30. $requests = array('name' => 'hogehogehoge'); $validations = array( 'name' => array( new Zend_Validate_StringLength(1, 10, 'utf-8'), 'messages' => array( 0 => $translate->_('User name should enter less than 100.'), ) ) ); Zend_Translate $validator = new Zend_Filter_Input(null, $validation); $valid = $validator->setData($requests)->isValid(); var_dump($input->getInvalid());
  • 31. $requests = array('name' => 'hogehogehoge'); $validations = array( 'name' => array( new Zend_Validate_StringLength(1, 10, 'utf-8'), 'messages' => array( 0 => $translate->_('User name should enter less than 100.'), ) ) ); Zend_Translate $validator = new Zend_Filter_Input(null, $validation); $valid = $validator->setData($requests)->isValid(); var_dump($input->getInvalid());
  • 32. $requests = array('name' => 'hogehogehoge'); $validations = array( 'name' => array( new Zend_Validate_StringLength(1, 10, 'utf-8'), 'messages' => array( 0 => $translate->_('User name should enter less than 100.'), ) ) ); Zend_Translate $validator = new Zend_Filter_Input(null, $validation); $valid = $validator->setData($requests)->isValid(); var_dump($input->getInvalid()); array(1) { ["name"]=> array(1) { ["stringLengthTooLong"]=> string(42) " 10 " }
  • 33. $requests = array('name' => 'hogehogehoge'); $validations = array( 'name' => array( new Zend_Validate_StringLength(1, 10, 'utf-8'), 'messages' => array( 0 => $translate->_('User name should enter less than 100.'), ) ) ); Zend_Translate $validator = new Zend_Filter_Input(null, $validation); $valid = $validator->setData($requests)->isValid(); var_dump($input->getInvalid()); array(1) { ["name"]=> array(1) { ["stringLengthTooLong"]=> string(42) " 10 " }
  • 34. $requests = array('email' => 'example@example.c'); $validations = array( 'email' => array( new Zend_Validate_EmailAddress(), 'messages' => array( 0 => $translate->_('Email is invaild.'), ) ) ) ); $validator = new Zend_Filter_Input(null, $validation); $valid = $validator->setData($requests)->isValid(); var_dump($input->getInvalid());
  • 35. $requests = array('email' => 'example@example.c'); $validations = array( 'email' => array( new Zend_Validate_EmailAddress(), 'messages' => array( 0 => $translate->_('Email is invaild.'), ) ) ) ); $validator = new Zend_Filter_Input(null, $validation); $valid = $validator->setData($requests)->isValid(); var_dump($input->getInvalid());
  • 36. array(1) { ["email"]=> array(1) { ["emailAddressInvalidHostname"]=> string(26) " " } }
  • 37. array(1) { ["email"]=> array(1) { ["emailAddressInvalidHostname"]=> string(26) " " } }
  • 38. _ | ∪ __ __ J| _ u ´ || | || | ● | ∪ __ __ J| _ u ´ || | || |
  • 39. array(1) { ["email"]=> array(3) { ["emailAddressInvalidHostname"]=> string(70) "'example.c' is no valid hostname for email address 'example@example.c'" ["hostnameUndecipherableTld"]=> string(68) "'example.c' appears to be a DNS hostname but cannot extract TLD part" ["hostnameLocalNameNotAllowed"]=> string(86) "'example.c' appears to be a local network name but local network names are not allowed" } }
  • 40. :::::: :::::::: ○ ○ |:::::::::::::::::::: __ __ :::: | _ ::::::::: |r -| || | :::::::::::: ` '´ || |
  • 41. :::::: :::::::: ○ ○ |:::::::::::::::::::: __ __ :::: | _ ::::::::: |r -| || | :::::::::::: ` '´ || |
  • 42. Zend_Validation_EmailAddress
  • 43. Zend_Translate translate Zend_Validate_Abstract Zend_Validate_Abstract::setDefaultTranslator($transla te);
  • 44. 1.9x, 1.10x http://github.com/heavenshell/gene/blob/0.2/app/ locales/ja/validate.ini http://github.com/heavenshell/zf-resources-lang-ja/ blob/master/Zend_Validate.php typo <(_ _)>
  • 45. [Ver1.9x] $locale = new Zend_Locale(); $path = '/path/to/ja/file.ini'; $translate = new Zend_Translate('ini', $path, $locale); Zend_Validate_Abstract::setDefaultTranslator($translate); [Ver1.10x] $locale = new Zend_Locale(); $path = '/path/to/resources/languages'; $scan = array('scan' => Zend_Translate::LOCALE_DIRECTORY); $translate = new Zend_Translate('array', $path, $locale, $scan); Zend_Validate_Abstract::setDefaultTranslator($translate);
  • 46. [Ver1.9x] $locale = new Zend_Locale(); $path = '/path/to/ja/file.ini'; $translate = new Zend_Translate('ini', $path, $locale); Zend_Validate_Abstract::setDefaultTranslator($translate); [Ver1.10x] array() $locale = new Zend_Locale(); $path = '/path/to/resources/languages'; $scan = array('scan' => Zend_Translate::LOCALE_DIRECTORY); $translate = new Zend_Translate('array', $path, $locale, $scan); Zend_Validate_Abstract::setDefaultTranslator($translate);
  • 47. → ( )
  • 48. trunk
  • 49. " '%value%' '%hostname%' " Zend_Validate.php Zend_Translate#addTranslation()
  • 50. return array( ''%hostname%' is no valid hostname for email address '%value%'' => ' ///' ); $locale = new Zend_Locale(); $path = '/path/to/resources/languages'; $scan = array('scan' => Zend_Translate::LOCALE_DIRECTORY); $translate = new Zend_Translate('array', $path, $locale, $scan); $anotherpath = '/path/to/resources/languages' . $lang . '/Another.php'; $translate->addTranslation($anotherpath); Zend_Validate_Abstract::setDefaultTranslator($translate); array(3) { ["emailAddressInvalidHostname"]=> string(72) " ///" ["hostnameUndecipherableTld"]=> string(82) "'examlpe.c' DNS TLD " ["hostnameLocalNameNotAllowed"]=> string(126) " 'examle.c' " }
  • 51. return array( ''%hostname%' is no valid hostname for email address '%value%'' => ' ///' ); $locale = new Zend_Locale(); $path = '/path/to/resources/languages'; $scan = array('scan' => Zend_Translate::LOCALE_DIRECTORY); $translate = new Zend_Translate('array', $path, $locale, $scan); $anotherpath = '/path/to/resources/languages' . $lang . '/Another.php'; $translate->addTranslation($anotherpath); Zend_Validate_Abstract::setDefaultTranslator($translate); array(3) { ["emailAddressInvalidHostname"]=> string(72) " ///" ["hostnameUndecipherableTld"]=> string(82) "'examlpe.c' DNS TLD " ["hostnameLocalNameNotAllowed"]=> string(126) " 'examle.c' " }
  • 52. return array( ''%hostname%' is no valid hostname for email address '%value%'' => ' ///' ); $locale = new Zend_Locale(); $path = '/path/to/resources/languages'; $scan = array('scan' => Zend_Translate::LOCALE_DIRECTORY); $translate = new Zend_Translate('array', $path, $locale, $scan); $anotherpath = '/path/to/resources/languages' . $lang . '/Another.php'; $translate->addTranslation($anotherpath); Zend_Validate_Abstract::setDefaultTranslator($translate); array(3) { ["emailAddressInvalidHostname"]=> string(72) " ///" ["hostnameUndecipherableTld"]=> string(82) "'examlpe.c' DNS TLD " ["hostnameLocalNameNotAllowed"]=> string(126) " 'examle.c' " }
  • 53. CRUD → → x( + )x Scafford
  • 54. FW TDD
  • 55. PHPUnit Stagehand_Testrunner … …
  • 56. CRUD → → x( + ) DB FW ( ) …
  • 57. Zend Framework Zend_Application Zend_Translate ( )
  • 58. Any questions?