0
2010/03/06 id:heavenshell
wozozo




 …
id:heavenshell (3/6                   )



  http://d.hatena.ne.jp/heavenshell

  http://twitter.com/heavenshell

  http:/...
2007                 (        )



(PEAR::Pager    ) → Phwittr

 Ver1.5



 Ver1.8   Zend_Application
Zend_Application



                   (2009/10)



  1.10
Zend_Application



                   (2009/10)



  1.10
Doctrine




  Doctrine   Doctrine   …

                   ←
ASP                    (         )

        CRUD




cron

               (JavaScript)       API
Zend Framework        1.9x

  http://github.com/heavenshell/gene
Zend_Db, Revulo_View_Phtmlc

  Doctrine                  ...
app
  |-- Gene.php
  |-- config
  |-- layouts
  | |-- admin
  | `-- index
  |-- locales
  | `-- ja
  |-- models
  | |-- Tab...
app
  |-- Gene.php
  |-- config
  |-- layouts
  | |-- admin
  | `-- index
  |-- locales
  | `-- ja
  |-- models         Zen...
app
  |-- Gene.php
  |-- config
  |-- layouts
  | |-- admin
  | `-- index
  |-- locales
  | `-- ja
  |-- models         Zen...
app
  |-- Gene.php
  |-- config
  |-- layouts
  | |-- admin
  | `-- index
  |-- locales
  | `-- ja
  |-- models         Zen...
app
  |-- Gene.php
  |-- config
  |-- layouts
  | |-- admin
  | `-- index
  |-- locales
  | `-- ja
  |-- models         Zen...
modules

          application
Plugin
 Zend_Controller_Plugin_Abstract

                    (              )



   CSRF

            ○○
Zend_Auth::getInstance()->getIdentity();
Q4M
 Openpear::Net_Q4M
                           …

 Zend_Queue

  Zend_Queue_Adapter_Q4m
1.7x
Zend Framework         use-at-will




                   DB, View, Session, Routing,
             etc
1.8

Zend_Application



  Dependency Injection
           noopable

1.7
Storefront (http://www.thepopeisdead.com/)
  Zend_Application

zfdebugdoctrine (http://github.com/danceric/zfdebugdoctrine...
Magento (http://www.magentocommerce.com/)
  OSS       EC

Live Commerce (http://www.live-commerce.com/)
              OSS
...
Zend_Application_Bootstrap_Bootstrap



application.ini                      ini

                                    appl...
Zend_Application_Bootstrap_Bootstrap
[application.ini]
bootstrap.path = GENE_LIB_PATH "/Bootstrap.php"
bootstrap.class = "...
(         junichiro
                      )

Zend_Db, Doctrine
                (           Zend_Db)

View                 ...
…
Validation
 Zend_Filter_Input
      (Zend_Form     )



 Zend_Translate
FW   ini



           Zend_Translate
$requests = array('name' => 'hogehogehoge');
$validations = array(
   'name' => array(
       new Zend_Validate_StringLeng...
$requests = array('name' => 'hogehogehoge');
$validations = array(
   'name' => array(
       new Zend_Validate_StringLeng...
$requests = array('name' => 'hogehogehoge');
$validations = array(
   'name' => array(
       new Zend_Validate_StringLeng...
$requests = array('name' => 'hogehogehoge');
$validations = array(
   'name' => array(
       new Zend_Validate_StringLeng...
$requests = array('name' => 'hogehogehoge');
$validations = array(
   'name' => array(
       new Zend_Validate_StringLeng...
$requests = array('email' => 'example@example.c');
$validations = array(
   'email' => array(
       new Zend_Validate_Ema...
$requests = array('email' => 'example@example.c');
$validations = array(
   'email' => array(
       new Zend_Validate_Ema...
array(1) {
 ["email"]=>
 array(1) {
  ["emailAddressInvalidHostname"]=>
  string(26) "                      "
    }
}
array(1) {
 ["email"]=>
 array(1) {
  ["emailAddressInvalidHostname"]=>
  string(26) "                      "
    }
}
_




| ∪       __   __       J|             _
      u        ´             ||            |
                              ...
array(1) {
  ["email"]=>
  array(3) {
    ["emailAddressInvalidHostname"]=>
    string(70) "'example.c' is no valid hostna...
::::::
   ::::::::       ○              ○
|::::::::::::::::::::       __       __   ::::    |   _
 :::::::::            |r...
::::::
   ::::::::       ○              ○
|::::::::::::::::::::       __       __   ::::    |   _
 :::::::::            |r...
Zend_Validation_EmailAddress
Zend_Translate

                            translate
  Zend_Validate_Abstract

Zend_Validate_Abstract::setDefaultTranslat...
1.9x, 1.10x

  http://github.com/heavenshell/gene/blob/0.2/app/
  locales/ja/validate.ini
  http://github.com/heavenshell/...
[Ver1.9x]
$locale = new Zend_Locale();
$path = '/path/to/ja/file.ini';
$translate = new Zend_Translate('ini', $path, $local...
[Ver1.9x]
$locale = new Zend_Locale();
$path = '/path/to/ja/file.ini';
$translate = new Zend_Translate('ini', $path, $local...
→   (   )
trunk
"                 '%value%'       '%hostname%'
                              "



Zend_Validate.php




    Zend_Translate...
return array(
  ''%hostname%' is no valid hostname for email address '%value%'' => '
                                     ...
return array(
  ''%hostname%' is no valid hostname for email address '%value%'' => '
                                     ...
return array(
  ''%hostname%' is no valid hostname for email address '%value%'' => '
                                     ...
CRUD



  →        →   x(     +    )x



Scafford
FW




TDD
PHPUnit

Stagehand_Testrunner



                                 …



                …
CRUD



     →   →       x(   +   )

DB

 FW (        )                …
Zend Framework

                  Zend_Application




 Zend_Translate



                       (    )
Any questions?
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Upcoming SlideShare
Loading in...5
×

Zend Framework Study@Tokyo #2

2,394

Published on

Zend Framework Study@Tokyo#2

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,394
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
24
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

























































  • Transcript of "Zend Framework Study@Tokyo #2"

    1. 1. 2010/03/06 id:heavenshell
    2. 2. wozozo …
    3. 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. 4. 2007 ( ) (PEAR::Pager ) → Phwittr Ver1.5 Ver1.8 Zend_Application
    5. 5. Zend_Application (2009/10) 1.10
    6. 6. Zend_Application (2009/10) 1.10
    7. 7. Doctrine Doctrine Doctrine … ←
    8. 8. ASP ( ) CRUD cron (JavaScript) API
    9. 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. 10. app |-- Gene.php |-- config |-- layouts | |-- admin | `-- index |-- locales | `-- ja |-- models | |-- Tables | `-- Tables.php |-- modules | |-- admin | |-- api | `-- index |-- plugins | `-- Gene |-- services `-- views `-- scripts
    11. 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. 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. 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. 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. 15. modules application
    16. 16. Plugin Zend_Controller_Plugin_Abstract ( ) CSRF ○○
    17. 17. Zend_Auth::getInstance()->getIdentity();
    18. 18. Q4M Openpear::Net_Q4M … Zend_Queue Zend_Queue_Adapter_Q4m
    19. 19. 1.7x Zend Framework use-at-will DB, View, Session, Routing, etc
    20. 20. 1.8 Zend_Application Dependency Injection noopable 1.7
    21. 21. Storefront (http://www.thepopeisdead.com/) Zend_Application zfdebugdoctrine (http://github.com/danceric/zfdebugdoctrine) ZFDebug Doctrine
    22. 22. Magento (http://www.magentocommerce.com/) OSS EC Live Commerce (http://www.live-commerce.com/) OSS TomatoCMS (http://tomatocms.com/) OSS CMS
    23. 23. Zend_Application_Bootstrap_Bootstrap application.ini ini application/ Bootstrap.php
    24. 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. 25. ( junichiro ) Zend_Db, Doctrine ( Zend_Db) View (ry Zend_Log Zend_Cache
    26. 26.
    27. 27. Validation Zend_Filter_Input (Zend_Form ) Zend_Translate
    28. 28. FW ini Zend_Translate
    29. 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. 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. 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. 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. 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. 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. 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. 36. array(1) { ["email"]=> array(1) { ["emailAddressInvalidHostname"]=> string(26) " " } }
    37. 37. array(1) { ["email"]=> array(1) { ["emailAddressInvalidHostname"]=> string(26) " " } }
    38. 38. _ | ∪ __ __ J| _ u ´ || | || | ● | ∪ __ __ J| _ u ´ || | || |
    39. 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. 40. :::::: :::::::: ○ ○ |:::::::::::::::::::: __ __ :::: | _ ::::::::: |r -| || | :::::::::::: ` '´ || |
    41. 41. :::::: :::::::: ○ ○ |:::::::::::::::::::: __ __ :::: | _ ::::::::: |r -| || | :::::::::::: ` '´ || |
    42. 42. Zend_Validation_EmailAddress
    43. 43. Zend_Translate translate Zend_Validate_Abstract Zend_Validate_Abstract::setDefaultTranslator($transla te);
    44. 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. 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. 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. 47. → ( )
    48. 48. trunk
    49. 49. " '%value%' '%hostname%' " Zend_Validate.php Zend_Translate#addTranslation()
    50. 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. 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. 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. 53. CRUD → → x( + )x Scafford
    54. 54. FW TDD
    55. 55. PHPUnit Stagehand_Testrunner … …
    56. 56. CRUD → → x( + ) DB FW ( ) …
    57. 57. Zend Framework Zend_Application Zend_Translate ( )
    58. 58. Any questions?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×