SlideShare a Scribd company logo
1 of 15
Download to read offline
Introduction to Zend_Controller
              and
     Actions with Paramters
‫מי אני?‬
                            ‫ניר טייב, בן 5.71 ממודיעין.‬   ‫‪‬‬



 ‫מתכנת לאינטרנט מזה 4-3 שנים בטכנולוגיות שונות. כיום‬      ‫‪‬‬


          ‫עובד ב-‪ Kontera.com‬בתור מתכנת ‪ Ruby‬ו-‪.Rails‬‬
‫בלוגר – כותב על בניית ‪ UI‬ב-‪ ,JavaScript‬צד שרת וחדשות‬      ‫‪‬‬


                    ‫בתחום. ‪http://webdev.blogli.co.il‬‬
    ‫מתכנת ב-‪ PHP‬כשנתיים ומשתמש ב-‪ ZF‬כ-3 חודשים.‬           ‫‪‬‬
‫‪ ,Zend Framework‬מה זה?‬
‫ספריית רכיבים - מכילה רכיבים שונים למטרות שונות,‬   ‫‪‬‬


          ‫בסיסיות ומבוקשות, שלא תלויים אחד בשני.‬
     ‫כתוב %001 ב-4.1.5 ‪ PHP‬בלי להתבסס על שום‬       ‫‪‬‬


                                  ‫‪.Extensions‬‬
‫קוד פתוח – כל אחד יכול לתרום לפריימוורק. משוחרר‬    ‫‪‬‬


                               ‫ברישיון ‪.BSD Like‬‬
‫‪ Zend_Controller‬מה זה?‬
‫חלק מרכיב ה-‪ MVC‬של ה-‪ ,Framework‬משמש ליצירת ה-‬       ‫‪‬‬


                 ‫‪ Controller‬באפליקצייה. ה-‪ C‬ב-‪.MVC‬‬
  ‫משמש לניתור בקשת ה-‪ HTTP‬ומחליט מה עושים איתה‬       ‫‪‬‬


                     ‫לפי הנתונים שנשלחו יחד איתה.‬
.‫, בסיס‬Zend_Controller
                   .Zend_Controller_Action ‫יורש את‬          



                   Controller-‫שם המחלקה יסתיים ב‬            

                          IndexController, BlogController
       :‫קו תחתון בשם המחלקה מסמן חלוקה לתיקיות‬              

         Foo_AdminController =< Foo/AdminController.php
‫, שם הקובץ יכיל מקף או‬CamelCase-‫מותר להשתמש ב‬               


                            .‫נקודה בסוף כל מילה‬
Controller Actions:
   HTTP.-‫ לניתור בקשת ה‬Controller-‫ – מתודה ב‬Action               

                http://domain.com/entries/list =< Action: list
   .‫“ היא חשופה לבחוץ‬Action“-‫כל מתודה שמסתיימת ב‬                 

                                    public function listAction
‫‪Front Controller‬‬

                   ‫מטפל בכל הבקשות.‬     ‫‪‬‬



            ‫מדביק את האפליקציה ביחד.‬    ‫‪‬‬



                   ‫מחזיר תשובה ללקוח.‬   ‫‪‬‬
‫איך הכל עובד?‬
‫קצת קוד‬

class EntriesController extens Zend_Controller_Action{

     public function indexAction(){
        echo 'Index !';
     }

     public function listAction(){
        echo '1, 2, 3';
     }

 }
‫טיפול ב-‪ QueryString‬וב-‪Post Data‬‬
              ‫‪‬המתודה ‪ _getParam‬לקריאה למשתנה אחד.‬
               ‫‪‬המתודה ‪ _getAllParams‬לקריאה של כולם.‬
 ‫‪‬המתודות מקבלות את כל המשתנים מה-‪ - QueryString‬שורת‬
‫הכתובת, ומה-‪ - Post Data‬המשתנים שנשלחים בגוף בקשת ה-‬
               ‫‪ ,HTTP‬לרוב בעזרת טופס עם ‪.method=post‬‬
‫ובדרך אחרת‬
‫להשתמש בפרמטרים של ה-‪ Actions‬לגישה ל-‪QueryString‬‬        ‫‪‬‬


                                       ‫וה-‪.Post Data‬‬
                                           ‫יתרונות:‬     ‫‪‬‬


                     ‫* רשימה ברורה של כל הפרמטרים‬
                                     ‫* ‪.type hinting‬‬
                                ‫* ערכי ברירת מחדל.‬
                                    ‫חסרונות: ביצועים.‬   ‫‪‬‬
:‫דוגמאות‬
       Framework Way:
        public function listAction(){

             $entry = $model-<find(intval($this-<_getParam(”id”)));

             $mode = @$this-<_getParam(”mode”);

             echo showContent($mode || 'plain', $entry-<data);

        }

       New Way:
        public function listAction($id, $mode='plain'){

              $entry = $model-<find(intval($id));

              echo showContent($mode, $content-<data);

        }
‫איך עושים זאת?‬

                                        ‫בשישה שלבים:‬            ‫‪‬‬

                         ‫1. יורשים את .‪Zend_Controller_Action‬‬
                               ‫2. דורסים את המתודה .‪dispatch‬‬
               ‫3. שומרים את כל ה-‪ Request Parameters‬במערך.‬
                ‫4. שומרים את כל ה-‪ Method Parameters‬במערך.‬
‫5. מפעילים את ה-‪ Action‬דינמית תוך כדי מיפוי המערך משלב 3 בסדר‬
                                                  ‫של שלב .4‬
     ‫6. כל ‪ Controller‬באפליקציה יירש מהמחלקה שיצרנו בשלב 1.‬
:‫מימוש התהליך‬
// 1. Make a new controller class the inherit Zend_Controller_Action
class Action_With_Parameters_Controller extends Zend_Controller_Action {
            // 2. Override the `dispatch` method
            public function dispatch($action) {
                     // 3. Get all request parameters
                     $params = $this-<_getAllParams();

                  // 4. Get all action method parameters
                  $method_params_array = $this-<get_action_params($action);

                  $data = array(); // It will sent to the action

                  foreach($method_params_array as $param) {
                          $name = $param-<getName();
                          if($param-<isOptional()) { // Check whether the parameter is optional
                                    // If there is no data to send, use the default
                                    $data[$name] = !empty($params[$name])? $params[$name] : $param-<getDefaultValue();
                          } elseif(empty($params[$name])) {
                                    // The parameter cannot be empty as defined
                                    throw new Exception('Parameter: '.$name.' Cannot be empty');
                          } else {
                                    $data[$name] = $params[$name];
                          }
                  }

                  // 5. Invoke the action and pass the request parameters as actions method parameters, according to their order and names.
                  call_user_func_array(array($this, $action), $data);
           }

           private function get_action_params($action) {
                    $classRef = new ReflectionObject($this);
                    $className = $classRef-<getName();
                    $funcRef = new ReflectionMethod($className, $action);
                    $paramsRef = $funcRef-<getParameters();
                    return $paramsRef;
           }
}
!‫תודה‬
                                                             :‫לעוד חומר בנושא‬         



                    http://framework.zend.com/manual/en/zend.controller.html      ●


                                      :‫השיטה המוצגת כאן, כתובה במאמר מפורט‬        ●


                                           http://devzone.zend.com/article/2855
                                                  .‫חשוב מאוד! לקרוא את התגובות‬
                             :Zend Framework ‫ של‬MVC-‫מצגת מקיפה על רכיב ה‬          ●




http://devzone.zend.com/content/zendcon_07_slides/Ophinney_Matthew_2007-ZendCon-M

More Related Content

What's hot

Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsPierre MARTIN
 
Ohp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 MojiretsuOhp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 Mojiretsusesejun
 
Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingErick Hitter
 
Recent Changes to jQuery's Internals
Recent Changes to jQuery's InternalsRecent Changes to jQuery's Internals
Recent Changes to jQuery's Internalsjeresig
 
บทที่6 update&delete
บทที่6 update&deleteบทที่6 update&delete
บทที่6 update&deletePalm Unnop
 
Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...
Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...
Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...Al-Mamun Sarkar
 
JavaOne 2017 | JShell: The Ultimate Missing Tool
 JavaOne 2017 | JShell: The Ultimate Missing Tool JavaOne 2017 | JShell: The Ultimate Missing Tool
JavaOne 2017 | JShell: The Ultimate Missing ToolHakan Özler
 
Seistech SQL code
Seistech SQL codeSeistech SQL code
Seistech SQL codeSimon Hoyle
 
Ôn tập KTTMDT
Ôn tập KTTMDTÔn tập KTTMDT
Ôn tập KTTMDTmrcoffee282
 

What's hot (14)

Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
CakeFest 2013 keynote
CakeFest 2013 keynoteCakeFest 2013 keynote
CakeFest 2013 keynote
 
Ohp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 MojiretsuOhp Seijoen H20 06 Mojiretsu
Ohp Seijoen H20 06 Mojiretsu
 
Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment Caching
 
Recent Changes to jQuery's Internals
Recent Changes to jQuery's InternalsRecent Changes to jQuery's Internals
Recent Changes to jQuery's Internals
 
Session 02
Session 02Session 02
Session 02
 
บทที่6 update&delete
บทที่6 update&deleteบทที่6 update&delete
บทที่6 update&delete
 
Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...
Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...
Web Design Course - Lecture 20 - Bootstrap Dropdown, Button group, Input grou...
 
Agile database access with CakePHP 3
Agile database access with CakePHP 3Agile database access with CakePHP 3
Agile database access with CakePHP 3
 
JavaOne 2017 | JShell: The Ultimate Missing Tool
 JavaOne 2017 | JShell: The Ultimate Missing Tool JavaOne 2017 | JShell: The Ultimate Missing Tool
JavaOne 2017 | JShell: The Ultimate Missing Tool
 
The Boy Scout Rule
The Boy Scout RuleThe Boy Scout Rule
The Boy Scout Rule
 
Seistech SQL code
Seistech SQL codeSeistech SQL code
Seistech SQL code
 
Ôn tập KTTMDT
Ôn tập KTTMDTÔn tập KTTMDT
Ôn tập KTTMDT
 
Drupal7 dbtng
Drupal7  dbtngDrupal7  dbtng
Drupal7 dbtng
 

Viewers also liked

Simple but usefull unit tests
Simple but usefull unit testsSimple but usefull unit tests
Simple but usefull unit testsNir Tayeb
 
Rogelio Umaña - Curriculum Vitae
Rogelio Umaña - Curriculum VitaeRogelio Umaña - Curriculum Vitae
Rogelio Umaña - Curriculum VitaeRogelio Umaña
 
Power 01
Power 01Power 01
Power 01wncleva
 
Extrasolar System
Extrasolar SystemExtrasolar System
Extrasolar Systemnoinoi79528
 
Crons &quot;Come Ready or Never Start&quot;
Crons &quot;Come Ready or Never Start&quot;Crons &quot;Come Ready or Never Start&quot;
Crons &quot;Come Ready or Never Start&quot;jaredmlane
 
Chiere mainframe integration
Chiere mainframe integrationChiere mainframe integration
Chiere mainframe integrationPaolo Chieregatti
 
Engagement, Evolution, Electronics: El Futuro se escribe con "E"
Engagement, Evolution, Electronics: El Futuro se escribe con "E"Engagement, Evolution, Electronics: El Futuro se escribe con "E"
Engagement, Evolution, Electronics: El Futuro se escribe con "E"Rogelio Umaña
 
Montoyas C
Montoyas CMontoyas C
Montoyas Cmrc2407
 
Romeo Must Die
Romeo Must DieRomeo Must Die
Romeo Must Diemrc2407
 
Montoyas C
Montoyas CMontoyas C
Montoyas Cmrc2407
 
Romeo & Juliet (1968)
Romeo & Juliet (1968)Romeo & Juliet (1968)
Romeo & Juliet (1968)mrc2407
 
Hablándole a Millennials: ¿Quiénes son los millennials?
Hablándole a Millennials: ¿Quiénes son los millennials?Hablándole a Millennials: ¿Quiénes son los millennials?
Hablándole a Millennials: ¿Quiénes son los millennials?Rogelio Umaña
 
Sistem Kardiovaskular
Sistem KardiovaskularSistem Kardiovaskular
Sistem Kardiovaskularimie
 

Viewers also liked (19)

Simple but usefull unit tests
Simple but usefull unit testsSimple but usefull unit tests
Simple but usefull unit tests
 
Rogelio Umaña - Curriculum Vitae
Rogelio Umaña - Curriculum VitaeRogelio Umaña - Curriculum Vitae
Rogelio Umaña - Curriculum Vitae
 
Steffmovile2
Steffmovile2Steffmovile2
Steffmovile2
 
Steffmovile2
Steffmovile2Steffmovile2
Steffmovile2
 
Power 01
Power 01Power 01
Power 01
 
Toyota 130601
Toyota 130601Toyota 130601
Toyota 130601
 
Extrasolar System
Extrasolar SystemExtrasolar System
Extrasolar System
 
Technology, innovation and business model: explaining Google success
Technology, innovation and business model: explaining Google successTechnology, innovation and business model: explaining Google success
Technology, innovation and business model: explaining Google success
 
Crons &quot;Come Ready or Never Start&quot;
Crons &quot;Come Ready or Never Start&quot;Crons &quot;Come Ready or Never Start&quot;
Crons &quot;Come Ready or Never Start&quot;
 
Chiere mainframe integration
Chiere mainframe integrationChiere mainframe integration
Chiere mainframe integration
 
Engagement, Evolution, Electronics: El Futuro se escribe con "E"
Engagement, Evolution, Electronics: El Futuro se escribe con "E"Engagement, Evolution, Electronics: El Futuro se escribe con "E"
Engagement, Evolution, Electronics: El Futuro se escribe con "E"
 
Tohoku100316
Tohoku100316Tohoku100316
Tohoku100316
 
Montoyas C
Montoyas CMontoyas C
Montoyas C
 
Romeo Must Die
Romeo Must DieRomeo Must Die
Romeo Must Die
 
Montoyas C
Montoyas CMontoyas C
Montoyas C
 
Romeo & Juliet (1968)
Romeo & Juliet (1968)Romeo & Juliet (1968)
Romeo & Juliet (1968)
 
West(1)
West(1)West(1)
West(1)
 
Hablándole a Millennials: ¿Quiénes son los millennials?
Hablándole a Millennials: ¿Quiénes son los millennials?Hablándole a Millennials: ¿Quiénes son los millennials?
Hablándole a Millennials: ¿Quiénes son los millennials?
 
Sistem Kardiovaskular
Sistem KardiovaskularSistem Kardiovaskular
Sistem Kardiovaskular
 

Similar to Hebrew, Introduction to Zend Controller And new technique

PHP - עבר הווה ועתיד
PHP - עבר הווה ועתידPHP - עבר הווה ועתיד
PHP - עבר הווה ועתידShahar Evron
 
PHP ואבטחה - חלק שני
PHP ואבטחה - חלק שניPHP ואבטחה - חלק שני
PHP ואבטחה - חלק שניShahar Evron
 
וורדפרס בחמש דקות (WordPress in five minutes, Hebrew))
וורדפרס בחמש דקות (WordPress in five minutes, Hebrew))וורדפרס בחמש דקות (WordPress in five minutes, Hebrew))
וורדפרס בחמש דקות (WordPress in five minutes, Hebrew))ran.hartstein
 
Slackware Tip
Slackware TipSlackware Tip
Slackware Tipmikilev3
 
עיצוב ויזואלי של מידע ליזי כהן שיעור 2
עיצוב ויזואלי של מידע   ליזי כהן   שיעור 2עיצוב ויזואלי של מידע   ליזי כהן   שיעור 2
עיצוב ויזואלי של מידע ליזי כהן שיעור 2lizicohen
 
IBM WebSphere Portal and Web Content management - Hebrew Overview
IBM WebSphere Portal and Web Content management - Hebrew OverviewIBM WebSphere Portal and Web Content management - Hebrew Overview
IBM WebSphere Portal and Web Content management - Hebrew OverviewDvir Reznik
 
GoLinks שיווק אינטרנט
GoLinks שיווק אינטרנטGoLinks שיווק אינטרנט
GoLinks שיווק אינטרנטadirr
 
על היפה רותם אפפל
על היפה רותם אפפלעל היפה רותם אפפל
על היפה רותם אפפלrotem42
 
עיצוב ויזואלי של מידע ליזי כהן שיעור 1
עיצוב ויזואלי של מידע   ליזי כהן   שיעור 1עיצוב ויזואלי של מידע   ליזי כהן   שיעור 1
עיצוב ויזואלי של מידע ליזי כהן שיעור 1lizicohen
 
פסק דין מאיר בוחבוט פדויי שבי
פסק דין מאיר  בוחבוט פדויי שביפסק דין מאיר  בוחבוט פדויי שבי
פסק דין מאיר בוחבוט פדויי שביsmile2life Israel
 
The National Water Conduit
The National Water ConduitThe National Water Conduit
The National Water ConduitIlan
 
ויקיפדיה ומאגרי מידע באינטרנט
ויקיפדיה ומאגרי מידע באינטרנטויקיפדיה ומאגרי מידע באינטרנט
ויקיפדיה ומאגרי מידע באינטרנטDror Kamir
 
New york sea level
New york sea levelNew york sea level
New york sea levelAnochi.com.
 
Digital Products - Ran Aroussi - Affilicon Fall 2008
Digital Products - Ran Aroussi - Affilicon Fall 2008Digital Products - Ran Aroussi - Affilicon Fall 2008
Digital Products - Ran Aroussi - Affilicon Fall 2008affilicon
 
Erp Round Table Summary
Erp Round Table SummaryErp Round Table Summary
Erp Round Table SummarySTKI
 
המהלך החדש של אמריקן אקספרס
המהלך החדש של אמריקן אקספרסהמהלך החדש של אמריקן אקספרס
המהלך החדש של אמריקן אקספרסguest7902b
 

Similar to Hebrew, Introduction to Zend Controller And new technique (20)

PHP - עבר הווה ועתיד
PHP - עבר הווה ועתידPHP - עבר הווה ועתיד
PHP - עבר הווה ועתיד
 
PHP ואבטחה - חלק שני
PHP ואבטחה - חלק שניPHP ואבטחה - חלק שני
PHP ואבטחה - חלק שני
 
וורדפרס בחמש דקות (WordPress in five minutes, Hebrew))
וורדפרס בחמש דקות (WordPress in five minutes, Hebrew))וורדפרס בחמש דקות (WordPress in five minutes, Hebrew))
וורדפרס בחמש דקות (WordPress in five minutes, Hebrew))
 
Slackware Tip
Slackware TipSlackware Tip
Slackware Tip
 
עיצוב ויזואלי של מידע ליזי כהן שיעור 2
עיצוב ויזואלי של מידע   ליזי כהן   שיעור 2עיצוב ויזואלי של מידע   ליזי כהן   שיעור 2
עיצוב ויזואלי של מידע ליזי כהן שיעור 2
 
IBM WebSphere Portal and Web Content management - Hebrew Overview
IBM WebSphere Portal and Web Content management - Hebrew OverviewIBM WebSphere Portal and Web Content management - Hebrew Overview
IBM WebSphere Portal and Web Content management - Hebrew Overview
 
Netica UX design
Netica UX designNetica UX design
Netica UX design
 
GoLinks שיווק אינטרנט
GoLinks שיווק אינטרנטGoLinks שיווק אינטרנט
GoLinks שיווק אינטרנט
 
על היפה רותם אפפל
על היפה רותם אפפלעל היפה רותם אפפל
על היפה רותם אפפל
 
Ella Jimmy Iseeqs Pm Heart
Ella Jimmy Iseeqs Pm HeartElla Jimmy Iseeqs Pm Heart
Ella Jimmy Iseeqs Pm Heart
 
עיצוב ויזואלי של מידע ליזי כהן שיעור 1
עיצוב ויזואלי של מידע   ליזי כהן   שיעור 1עיצוב ויזואלי של מידע   ליזי כהן   שיעור 1
עיצוב ויזואלי של מידע ליזי כהן שיעור 1
 
פסק דין מאיר בוחבוט פדויי שבי
פסק דין מאיר  בוחבוט פדויי שביפסק דין מאיר  בוחבוט פדויי שבי
פסק דין מאיר בוחבוט פדויי שבי
 
The National Water Conduit
The National Water ConduitThe National Water Conduit
The National Water Conduit
 
Biofeedback 8 Sc Operation
Biofeedback 8 Sc OperationBiofeedback 8 Sc Operation
Biofeedback 8 Sc Operation
 
Profile
ProfileProfile
Profile
 
ויקיפדיה ומאגרי מידע באינטרנט
ויקיפדיה ומאגרי מידע באינטרנטויקיפדיה ומאגרי מידע באינטרנט
ויקיפדיה ומאגרי מידע באינטרנט
 
New york sea level
New york sea levelNew york sea level
New york sea level
 
Digital Products - Ran Aroussi - Affilicon Fall 2008
Digital Products - Ran Aroussi - Affilicon Fall 2008Digital Products - Ran Aroussi - Affilicon Fall 2008
Digital Products - Ran Aroussi - Affilicon Fall 2008
 
Erp Round Table Summary
Erp Round Table SummaryErp Round Table Summary
Erp Round Table Summary
 
המהלך החדש של אמריקן אקספרס
המהלך החדש של אמריקן אקספרסהמהלך החדש של אמריקן אקספרס
המהלך החדש של אמריקן אקספרס
 

Recently uploaded

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 

Recently uploaded (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 

Hebrew, Introduction to Zend Controller And new technique

  • 1. Introduction to Zend_Controller and Actions with Paramters
  • 2. ‫מי אני?‬ ‫ניר טייב, בן 5.71 ממודיעין.‬ ‫‪‬‬ ‫מתכנת לאינטרנט מזה 4-3 שנים בטכנולוגיות שונות. כיום‬ ‫‪‬‬ ‫עובד ב-‪ Kontera.com‬בתור מתכנת ‪ Ruby‬ו-‪.Rails‬‬ ‫בלוגר – כותב על בניית ‪ UI‬ב-‪ ,JavaScript‬צד שרת וחדשות‬ ‫‪‬‬ ‫בתחום. ‪http://webdev.blogli.co.il‬‬ ‫מתכנת ב-‪ PHP‬כשנתיים ומשתמש ב-‪ ZF‬כ-3 חודשים.‬ ‫‪‬‬
  • 3. ‫‪ ,Zend Framework‬מה זה?‬ ‫ספריית רכיבים - מכילה רכיבים שונים למטרות שונות,‬ ‫‪‬‬ ‫בסיסיות ומבוקשות, שלא תלויים אחד בשני.‬ ‫כתוב %001 ב-4.1.5 ‪ PHP‬בלי להתבסס על שום‬ ‫‪‬‬ ‫‪.Extensions‬‬ ‫קוד פתוח – כל אחד יכול לתרום לפריימוורק. משוחרר‬ ‫‪‬‬ ‫ברישיון ‪.BSD Like‬‬
  • 4. ‫‪ Zend_Controller‬מה זה?‬ ‫חלק מרכיב ה-‪ MVC‬של ה-‪ ,Framework‬משמש ליצירת ה-‬ ‫‪‬‬ ‫‪ Controller‬באפליקצייה. ה-‪ C‬ב-‪.MVC‬‬ ‫משמש לניתור בקשת ה-‪ HTTP‬ומחליט מה עושים איתה‬ ‫‪‬‬ ‫לפי הנתונים שנשלחו יחד איתה.‬
  • 5. .‫, בסיס‬Zend_Controller .Zend_Controller_Action ‫יורש את‬  Controller-‫שם המחלקה יסתיים ב‬  IndexController, BlogController :‫קו תחתון בשם המחלקה מסמן חלוקה לתיקיות‬  Foo_AdminController =< Foo/AdminController.php ‫, שם הקובץ יכיל מקף או‬CamelCase-‫מותר להשתמש ב‬  .‫נקודה בסוף כל מילה‬
  • 6. Controller Actions: HTTP.-‫ לניתור בקשת ה‬Controller-‫ – מתודה ב‬Action  http://domain.com/entries/list =< Action: list .‫“ היא חשופה לבחוץ‬Action“-‫כל מתודה שמסתיימת ב‬  public function listAction
  • 7. ‫‪Front Controller‬‬ ‫מטפל בכל הבקשות.‬ ‫‪‬‬ ‫מדביק את האפליקציה ביחד.‬ ‫‪‬‬ ‫מחזיר תשובה ללקוח.‬ ‫‪‬‬
  • 9. ‫קצת קוד‬ class EntriesController extens Zend_Controller_Action{ public function indexAction(){ echo 'Index !'; } public function listAction(){ echo '1, 2, 3'; } }
  • 10. ‫טיפול ב-‪ QueryString‬וב-‪Post Data‬‬ ‫‪‬המתודה ‪ _getParam‬לקריאה למשתנה אחד.‬ ‫‪‬המתודה ‪ _getAllParams‬לקריאה של כולם.‬ ‫‪‬המתודות מקבלות את כל המשתנים מה-‪ - QueryString‬שורת‬ ‫הכתובת, ומה-‪ - Post Data‬המשתנים שנשלחים בגוף בקשת ה-‬ ‫‪ ,HTTP‬לרוב בעזרת טופס עם ‪.method=post‬‬
  • 11. ‫ובדרך אחרת‬ ‫להשתמש בפרמטרים של ה-‪ Actions‬לגישה ל-‪QueryString‬‬ ‫‪‬‬ ‫וה-‪.Post Data‬‬ ‫יתרונות:‬ ‫‪‬‬ ‫* רשימה ברורה של כל הפרמטרים‬ ‫* ‪.type hinting‬‬ ‫* ערכי ברירת מחדל.‬ ‫חסרונות: ביצועים.‬ ‫‪‬‬
  • 12. :‫דוגמאות‬  Framework Way: public function listAction(){ $entry = $model-<find(intval($this-<_getParam(”id”))); $mode = @$this-<_getParam(”mode”); echo showContent($mode || 'plain', $entry-<data); }  New Way: public function listAction($id, $mode='plain'){ $entry = $model-<find(intval($id)); echo showContent($mode, $content-<data); }
  • 13. ‫איך עושים זאת?‬ ‫בשישה שלבים:‬ ‫‪‬‬ ‫1. יורשים את .‪Zend_Controller_Action‬‬ ‫2. דורסים את המתודה .‪dispatch‬‬ ‫3. שומרים את כל ה-‪ Request Parameters‬במערך.‬ ‫4. שומרים את כל ה-‪ Method Parameters‬במערך.‬ ‫5. מפעילים את ה-‪ Action‬דינמית תוך כדי מיפוי המערך משלב 3 בסדר‬ ‫של שלב .4‬ ‫6. כל ‪ Controller‬באפליקציה יירש מהמחלקה שיצרנו בשלב 1.‬
  • 14. :‫מימוש התהליך‬ // 1. Make a new controller class the inherit Zend_Controller_Action class Action_With_Parameters_Controller extends Zend_Controller_Action { // 2. Override the `dispatch` method public function dispatch($action) { // 3. Get all request parameters $params = $this-<_getAllParams(); // 4. Get all action method parameters $method_params_array = $this-<get_action_params($action); $data = array(); // It will sent to the action foreach($method_params_array as $param) { $name = $param-<getName(); if($param-<isOptional()) { // Check whether the parameter is optional // If there is no data to send, use the default $data[$name] = !empty($params[$name])? $params[$name] : $param-<getDefaultValue(); } elseif(empty($params[$name])) { // The parameter cannot be empty as defined throw new Exception('Parameter: '.$name.' Cannot be empty'); } else { $data[$name] = $params[$name]; } } // 5. Invoke the action and pass the request parameters as actions method parameters, according to their order and names. call_user_func_array(array($this, $action), $data); } private function get_action_params($action) { $classRef = new ReflectionObject($this); $className = $classRef-<getName(); $funcRef = new ReflectionMethod($className, $action); $paramsRef = $funcRef-<getParameters(); return $paramsRef; } }
  • 15. !‫תודה‬ :‫לעוד חומר בנושא‬  http://framework.zend.com/manual/en/zend.controller.html ● :‫השיטה המוצגת כאן, כתובה במאמר מפורט‬ ● http://devzone.zend.com/article/2855 .‫חשוב מאוד! לקרוא את התגובות‬ :Zend Framework ‫ של‬MVC-‫מצגת מקיפה על רכיב ה‬ ● http://devzone.zend.com/content/zendcon_07_slides/Ophinney_Matthew_2007-ZendCon-M