PHPBootcamp - Zend Framework


Published on

Short introduction into the Zend Framework with some examples for the I18N core given at the PHPBootcamp. Other presented frameworks were Joomla and Symphony

Published in: Technology, Education
  • Njce! Thanks for sharing.
    Are you sure you want to  Yes  No
    Your message goes here
  • Xbox Live & Microsoft points codes get here free: all codes are working, try it - no regret Download Link Here :- -----------------------------------------------------------
    Are you sure you want to  Yes  No
    Your message goes here
  • Impressive presentation on ’PHPBootcamp - Zend Framework'. You’ve shown your credibility on presentation with this slideshow. This one deserves thumbs up. I’m John, owner of . Hope to see more quality slides from you.

    Best wishes.
    Are you sure you want to  Yes  No
    Your message goes here
  • outstanding demonstration..convinced me to have a hardlook at my company model..great
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

PHPBootcamp - Zend Framework

  1. 1. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most popular web programming language gets even better with an easy to use framework for developing the next generation of web applications.
  2. 2. What is the Zend Framework? <ul><li>PHP 5 class library for web development </li></ul><ul><li>Free, open source, BSD license (like PHP) </li></ul><ul><li>+150,000 lines of code </li></ul><ul><li>Emphasis on quality: 90%+ unit test coverage </li></ul><ul><li>Solutions are “extremely simple” – solving the 80% usage case, and allowing for extensibility </li></ul><ul><li>+200,000 downloads </li></ul><ul><li> </li></ul>
  3. 3. History of the Zend Framework <ul><li>Brought to live at 19.October 2005 by Zend at the IST in California </li></ul><ul><li>First official preview 03.March.2006 (V0.1.1) </li></ul><ul><li>12 official releases since 2006 </li></ul><ul><li>Actual release 1.0RC1 </li></ul><ul><li>Official 1.0 proposed for July </li></ul>
  4. 4. What’s in the Zend Framework? <ul><ul><li>MVC web app framework (model-view-controller) </li></ul></ul><ul><ul><li>Database access </li></ul></ul><ul><ul><li>Lucene-compatible Search engine </li></ul></ul><ul><ul><li>Input filtering and validation </li></ul></ul><ul><ul><li>Authentication </li></ul></ul><ul><ul><li>Access control </li></ul></ul><ul><ul><li>Session handling </li></ul></ul><ul><ul><li>I18N, translation </li></ul></ul><ul><ul><li>PDF file reading and writing </li></ul></ul><ul><ul><li>HTTP client </li></ul></ul><ul><ul><li>XmlRpc </li></ul></ul><ul><ul><li>REST web services </li></ul></ul><ul><ul><li>RSS and Atom feeds </li></ul></ul><ul><ul><li>Google Gdata client </li></ul></ul><ul><ul><li>Logging </li></ul></ul><ul><ul><li>Mail reading and sending </li></ul></ul><ul><ul><li>Caching </li></ul></ul><ul><ul><li>Configuration file handling </li></ul></ul><ul><ul><li>Command-line option parsing </li></ul></ul><ul><li>Simple, convenient object-oriented solutions to common web application development tasks: </li></ul>
  5. 5. API Overview
  6. 6. Component Overview 1/4 <ul><li>MVC Layer </li></ul><ul><ul><li>Zend_Controller – Controller Pattern </li></ul></ul><ul><ul><li>Zend_View – View Pattern </li></ul></ul><ul><li>DATA Layer </li></ul><ul><ul><li>Zend_Db – Database Handling </li></ul></ul><ul><ul><li>Zend_Pdf – PDF Creation and Handling </li></ul></ul><ul><ul><li>Zend_Search – Lucene Search </li></ul></ul><ul><li>I18N Layer </li></ul><ul><ul><li>Zend_Date – Localized Date handling </li></ul></ul><ul><ul><li>Zend_Locale – I18N Base class, Localisation </li></ul></ul><ul><ul><li>Zend_Measure – Measurements, conversions </li></ul></ul><ul><ul><li>Zend_Translate – Translations </li></ul></ul>
  7. 7. Component Overview 2/4 <ul><li>WEB Services Layer </li></ul><ul><ul><li>Zend_Feed – RSS und ATOM Feeds </li></ul></ul><ul><ul><li>Zend_GData – Google Data Client </li></ul></ul><ul><ul><li>Zend_Http – HTTP Client and Server </li></ul></ul><ul><ul><li>Zend_Json – JSON Access </li></ul></ul><ul><ul><li>Zend_Rest – Rest Client and Server </li></ul></ul><ul><ul><li>Zend_XmlRpc – XMLRPC Client and Server </li></ul></ul><ul><ul><li>Zend_Service – Access for different web services including </li></ul></ul><ul><ul><ul><li>Askimet </li></ul></ul></ul><ul><ul><ul><li>Amazon </li></ul></ul></ul><ul><ul><ul><li>Audioscrobbler </li></ul></ul></ul><ul><ul><ul><li>Delicious </li></ul></ul></ul><ul><ul><ul><li>Flickr </li></ul></ul></ul><ul><ul><ul><li>Simpy </li></ul></ul></ul><ul><ul><ul><li>Yahoo </li></ul></ul></ul><ul><ul><ul><li>and more are already in the incubator or proposed </li></ul></ul></ul>
  8. 8. Component Overview 3/4 <ul><li>Core Layer </li></ul><ul><ul><li>Zend_Acl – Access Controll List, Limiting ressources, roles, users </li></ul></ul><ul><ul><li>Zend_Auth – Authentication </li></ul></ul><ul><ul><li>Zend_Cache – Caching </li></ul></ul><ul><ul><li>Zend_Config – Configuration Handling </li></ul></ul><ul><ul><li>Zend_Console – Console Options Handling </li></ul></ul><ul><ul><li>Zend_Filter – Filtering Input data </li></ul></ul><ul><ul><li>Zend_Log – Log file Handling (log4j based) </li></ul></ul><ul><ul><li>Zend_Mail – Mail sending and receiving </li></ul></ul><ul><ul><li>Zend_Memory – Memory Access when memory is limited </li></ul></ul><ul><ul><li>Zend_Registry – Storing data within an application registry </li></ul></ul><ul><ul><li>Zend_Session – Session Handling </li></ul></ul><ul><ul><li>Zend_Validate – Validating </li></ul></ul>
  9. 9. Component Overview 4/4 <ul><li>Incubator Components… after 1.0 release, already partitial useable </li></ul><ul><ul><li>Zend_Currency – Localized currency handling (I18N) </li></ul></ul><ul><ul><li>Zend_Environment – (Core) </li></ul></ul><ul><ul><li>Zend_Form – Form handling (MVC) </li></ul></ul><ul><ul><li>Zend_Soap – Soap Client and Server (Services) </li></ul></ul><ul><ul><li>Zend_Timesync – Timeserver access (NTP, SNTP) (I18N) </li></ul></ul><ul><li>Future Components </li></ul><ul><ul><li>Several additional components proposed including… </li></ul></ul><ul><ul><li>LDAP, Calendar, PayPal, YouTube, Yaml… </li></ul></ul><ul><li>Proposals </li></ul><ul><ul><li> </li></ul></ul>
  10. 10. Directory layout <ul><li>/Zend </li></ul><ul><li>/Zend/Locale.php </li></ul><ul><li>/Zend/Locale </li></ul><ul><li>/Zend/Locale/Format.php </li></ul><ul><li>… </li></ul><ul><li>A component is always a base class and all subclasses in it’s same named directory. .. </li></ul><ul><li>This way single components can be used without installing the complete framework… </li></ul>
  11. 11. Minimum requirements <ul><li>Some Minimum requirements </li></ul><ul><ul><li>PHP 5.1.4 </li></ul></ul><ul><ul><li>Webserver </li></ul></ul><ul><ul><li>Standard installation </li></ul></ul><ul><ul><li>commonly no additional extensions needed </li></ul></ul><ul><li>That’s all… </li></ul>
  12. 12. A simple example 1/4 <ul><li>A simple example – Localisation: </li></ul><ul><ul><li><?php </li></ul></ul><ul><ul><li>require_once ‘Zend/Locale.php’; </li></ul></ul><ul><ul><li>$locale = new Zend_Locale(); </li></ul></ul><ul><ul><li>print $locale->toString(); </li></ul></ul>
  13. 13. A simple example 2/4 <ul><li>Each class can be used alone: </li></ul><ul><ul><li><?php </li></ul></ul><ul><ul><li>require_once ‘Zend/Locale.php’; </li></ul></ul><ul><ul><li>$locale = new Zend_Locale(); </li></ul></ul><ul><ul><li>print $locale->toString(); </li></ul></ul><ul><li>Requiring the file is enough… </li></ul><ul><li>Each component knows which other components it has to load </li></ul>
  14. 14. A simple example 3/4 <ul><li>Location of the ZF components: </li></ul><ul><ul><li><?php </li></ul></ul><ul><ul><li>require_once ‘Zend/Locale.php’; </li></ul></ul><ul><ul><li>$locale = new Zend_Locale(); </li></ul></ul><ul><ul><li>print $locale->toString(); </li></ul></ul><ul><li>All components are in the same directory. </li></ul>
  15. 15. A simple example 4/4 <ul><li>The result: our users language </li></ul><ul><ul><li><?php </li></ul></ul><ul><ul><li>require_once ‘Zend/Locale.php’; </li></ul></ul><ul><ul><li>$locale = new Zend_Locale(); </li></ul></ul><ul><ul><li>print $locale->toString(); </li></ul></ul><ul><li>The visiting users language… </li></ul>
  16. 16. Localisation <ul><li>Possibilities of Zend_Locale </li></ul><ul><ul><li>Get the client users languages </li></ul></ul><ul><ul><li>Get localized data </li></ul></ul><ul><ul><li>Base localisation class for ZF </li></ul></ul><ul><ul><li>Locale aware formating of numbers, dates and times </li></ul></ul><ul><li>Example1 </li></ul><ul><li>Example2 </li></ul>
  17. 17. Localized data <ul><li>Localized and translated data: </li></ul><ul><ul><li>Translation for all languages </li></ul></ul><ul><ul><li>Translation for all scripts </li></ul></ul><ul><ul><li>Translation for countries and territories </li></ul></ul><ul><ul><li>Calendar formats </li></ul></ul><ul><ul><li>Month- and Day names </li></ul></ul><ul><ul><li>Standard formats for Date and Time </li></ul></ul><ul><ul><li>Currency name, signs and formats </li></ul></ul><ul><ul><li>Characters used in this language </li></ul></ul><ul><ul><li>Yes and no strings </li></ul></ul><ul><ul><li>… </li></ul></ul>
  18. 18. Locale aware formating rules <ul><li>Zend_Locale_Format </li></ul><ul><ul><li>Converting from one script to another </li></ul></ul><ul><ul><li>Normalizing of numbers (12,345.45 -> 12345.45) </li></ul></ul><ul><ul><li>Localizing of numbers (12345.45 -> 12,345.45) </li></ul></ul><ul><ul><li>Checking if a localized number is valid </li></ul></ul><ul><ul><li>Normalizing date & time inputs </li></ul></ul><ul><ul><li>Checking if a localized date or time input is valid </li></ul></ul>
  19. 19. Script conversion <ul><li>From european digits to arabic digits and visa versa </li></ul><ul><li><?php require_once ‘Zend/Locale.php’; </li></ul><ul><li>$number = “12345”; </li></ul><ul><li>$converted = Zend_Locale_Format::convertNumerals($number, ‘Latn’, ‘Arab’); </li></ul><ul><li>$european = Zend_Locale_Format::convertNumerals($converted, ‘Arab’, ‘Latn’); </li></ul><ul><li>Example3 </li></ul>
  20. 20. Number normalization <ul><li>Normalizing numbers </li></ul><ul><li><?php require_once ‘Zend/Locale.php’; </li></ul><ul><li>$number = “12.345,67”; </li></ul><ul><li>$normal = Zend_Locale_Format::getNumber($number); </li></ul><ul><li>Example4 </li></ul>
  21. 21. Number localization <ul><li>Localizing numbers </li></ul><ul><li><?php require_once ‘Zend/Locale.php’; </li></ul><ul><li>$number = 12345.67; </li></ul><ul><li>$normal = Zend_Locale_Format::toNumber($number); </li></ul><ul><li>Example5 </li></ul><ul><li>Example8 </li></ul>
  22. 22. Multilingual applications <ul><li>Making applications running worldwide </li></ul><ul><ul><li>Translating output </li></ul></ul><ul><ul><li>Format of date and time </li></ul></ul><ul><ul><li>Format of numbers </li></ul></ul><ul><ul><li>Format of currencies </li></ul></ul><ul><ul><li>Knowing allowed characters of a language </li></ul></ul>
  23. 23. Translation <ul><li>Gettext… the old way </li></ul><ul><li><?php bindtextdomain(‘domain’, ‘path’); textdomain(‘domain’); print gettext(‘my translation’); </li></ul><ul><li>Fixed directory layout /path/LC_ALL/locale/ </li></ul><ul><li>Needs an extension to work </li></ul><ul><li>Complicated for people unfamiliar to GNUs gettext </li></ul>
  24. 24. Zend_Translate <ul><li>Gettext… with Zend_Translate </li></ul><ul><li><?php require_once ‘Zend/Translate.php’; // within bootstrap file $tr = new Zend_Translate(AN_ARRAY, ‘Path/to/’, ‘de’); print $tr->_(‘my translation’); </li></ul><ul><li>No fixed directory layout </li></ul><ul><li>No extension needed </li></ul><ul><li>Same API for all sources </li></ul>
  25. 25. Zend_Translate sources <ul><li>Zend_Translate sources </li></ul><ul><ul><li>One API for all sources </li></ul></ul><ul><ul><li>Supported sources are: </li></ul></ul><ul><ul><ul><li>Array </li></ul></ul></ul><ul><ul><ul><li>Csv </li></ul></ul></ul><ul><ul><ul><li>Gettext </li></ul></ul></ul><ul><ul><ul><li>Qt </li></ul></ul></ul><ul><ul><ul><li>Tmx </li></ul></ul></ul><ul><ul><ul><li>Xliff </li></ul></ul></ul><ul><ul><li>More to come (SQL, XmlTm, …) </li></ul></ul>
  26. 26. Switching sources <ul><li>Changing sources ? No problem… </li></ul><ul><li><?php require_once ‘Zend/Translate.php’; // within bootstrap file $tr = new Zend_Translate( AN_CSV , ‘Path/to/ myfile.csv ’, ‘de’); print $tr->_(‘my translation’); </li></ul><ul><li><?php require_once ‘Zend/Translate.php’; // within bootstrap file $tr = new Zend_Translate( AN_GETTEXT , ‘Path/to/ ’, ‘de’); print $tr->_(‘my translation’); </li></ul><ul><li>Just one small change, same API </li></ul>
  27. 27. Conditional translating <ul><li>Is a string translateable ? </li></ul><ul><li><?php require_once ‘Zend/Translate.php’; // within bootstrap file $tr = new Zend_Translate(AN_CSV, ‘Path/to/myfile.csv’, ‘de’); if ($tr->isTranslated(‘my translation’)) { // do something } else { // no translation, do something else } </li></ul><ul><li>Not possible with php </li></ul>
  28. 28. Allowed characters <ul><li>Verifying input… but localized ? </li></ul><ul><li><?php require_once ‘Zend/Locale.php’; // within bootstrap file $tr = new Zend_Locale(); $de = $tr->getTranslationList(‘characters’, ‘de’); $fr = $tr->getTranslationList(‘characters’, ‘fr’); </li></ul><ul><li>For more than 128 languages </li></ul><ul><li>Example6 </li></ul>
  29. 29. Language selectbox <ul><li>Creating a localized selectbox for languages ? </li></ul><ul><li><?php require_once ‘Zend/Locale.php’; // within bootstrap file $tr = new Zend_Locale(); $de = $tr->getTranslationList(‘language’); foreach ($de as $key => $value) { $fr = $tr->getTranslationList(‘language’, $key); print $fr[$key]; } </li></ul><ul><li>Example7 </li></ul>
  30. 30. Yes or No <ul><li>How to realize a yes-no for every language ? </li></ul><ul><li><?php require_once ‘Zend/Locale.php’; // within bootstrap file $tr = new Zend_Locale(); $de = $tr->getQuestion(); </li></ul><ul><li>Example9 </li></ul>
  31. 31. Normalizing dates <ul><li>Monthnames / Daynames </li></ul><ul><li><?php require_once ‘Zend/Locale.php’; // within bootstrap file $date = “12.März.2007 20:15:00”; $tr = new Zend_Locale_Format::getDate($date, ‘de’); print_r($tr); </li></ul><ul><li>Example10 </li></ul>
  32. 32. Working with dates <ul><li>Zend_Date </li></ul><ul><ul><li>One class </li></ul></ul><ul><ul><li>Handles all meanings (date, time, parts, sun…) </li></ul></ul><ul><ul><li>Simple API </li></ul></ul><ul><ul><li>Easy handling </li></ul></ul><ul><ul><li>ISO Standard also PHP’s GNU supported </li></ul></ul><ul><ul><li>Knows more than 50 standard represenations </li></ul></ul><ul><ul><li>Unlimited (more than 64bit) dates supported </li></ul></ul>
  33. 33. Working with dates 2 <ul><li>Capabilities </li></ul><ul><ul><li>Computing dates </li></ul></ul><ul><ul><li>Get sunset / sunrise for cities </li></ul></ul><ul><ul><li>Easy changing with ISO ( dd.MM.yyyy HH:mm:ss a ) </li></ul></ul><ul><ul><li>Supports different standards ( ISO, GNU, RFC2822 (mail), W3C, RSS, Cookies…) </li></ul></ul>
  34. 34. Date maths <ul><li>Computing dates </li></ul><ul><ul><li>Normalized </li></ul></ul><ul><ul><li>Localized </li></ul></ul><ul><ul><li>Added / Substracted </li></ul></ul><ul><ul><li>Checked (earlier, later, equal </li></ul></ul><ul><ul><li>Splitted </li></ul></ul><ul><ul><li>Converted </li></ul></ul><ul><ul><li>… </li></ul></ul>
  35. 35. Date example <ul><li>Example11 </li></ul><ul><ul><li>$date = new Zend_Date(‘20070414T122050’, Zend_Date::ISO_8601); $date->addMonth(2); $date->subYear(6); </li></ul></ul><ul><ul><li>If ($date->isLeapYear()) { // LeapYear } else { // NO LeapYear } </li></ul></ul>
  36. 36. Checking dates <ul><li>Check if a date is a date </li></ul><ul><ul><li>If ( Zend_Date::isDate(’14. April. 2007 10:20:55’)) </li></ul></ul><ul><li>Example12 </li></ul><ul><li>Compare parts </li></ul><ul><ul><li>If ( $date->compareWeekday(2)) </li></ul></ul><ul><li>Example13 </li></ul>
  37. 37. Stay up <ul><li>Calculating sunset / sunrise </li></ul><ul><ul><li>With php… complicated </li></ul></ul><ul><ul><li>With Zend_Date… just know your city </li></ul></ul><ul><ul><li>$city = Zend_Date_Cities::City(‘Amsterdam’); $date = new Zend_Date(); $uptime = $date->getSunrise($city) </li></ul></ul>
  38. 38. At the end <ul><li>Simple solution </li></ul><ul><li>Easy handling </li></ul><ul><li>Easy extending – 80% use case </li></ul><ul><li>High quality </li></ul><ul><li>Growing fast </li></ul>
  39. 39. Contact us <ul><li> </li></ul><ul><li>Mailinglist [email_address] </li></ul><ul><li>Instant messager </li></ul>
  40. 40. Thanks