SlideShare uma empresa Scribd logo
1 de 21
Zend FrameworkAflevering 2 zendframework.bartj.com
Later & Vandaag Later?? Adobe FLEX3 & AIR Case: Hondenbemiddeling Dierenbescherming Vandaag URL Formaat Zend_Config Zend_Log Zend_View Zend_Layout
URL Formaat URL Formaat /index/index /tickets/index tickets is de controller index is de action /tickets/bekijkticket/ticketid/12345 tickets is de controller bekijkticket is de action ticketid is de naam/key van parameter1 12345 is de waarde van ticketid
URL Formaat Bestand: application/controllers/IndexController.php classIndexControllerextends Zend_Controller_Action { 		public functionindexAction() { 			// Hier gaat het gebeuren 		}  } Bestand: application/controllers/TicketsController.php classTicketsControllerextends Zend_Controller_Action { 		public functionindexAction() { 			// Index van de Tickets 		} 		public functionbekijkticketAction() { 			// Hier komt de code om tickets te bekijken 		} }
Een klein stukje Zend_View Bestand: application/controllers/IndexController.php classIndexControllerextends Zend_Controller_Action { 		public functionindexAction() { 			$this->view->tekst = “hallooohallooo”; 		}  } Bestand: application/views/scripts/index/index.phtml <html><head><title>Test van Hoi</title></head> <body> <?= $this->tekst ?> </body> </html>
Zend_Config Zend_Config gebruik je om instellingen in te lezen en op te slaan Bijvoorbeeld MySQL Instellingen Kan via XML INI Naslagwerk http://framework.zend.com/manual/en/zend.config.html
Zend_Config – INI File Inhoud INI File: [productie] hostname = www.bartj.com database.adapter = pdo_mysql database.params.hostname = mysql.bartj.com database.params.username = dbuser database.params.password = secret database.params.dbname = dbname ; test instellingen, rest overerven van productie [test:productie] database.params.hostname = test.mysql.bartj.com database.params.username = devuser database.params.password = devsecret
Zend_Config – INI File - 2 $config = new Zend_Config_Ini(bestand, sectie, instellingen); v.b. $config = new Zend_Config_Ini(‘config.ini, ‘test’); Instellingen (Array) allowModifications -> true/false nestSeparator -> “.” (default)
Zend_Registry Zend_Registry wordt gebruikt om informatie op te slaan die overal in de applicatie beschikbaar moet zijn Functies Zend_Registry::get(naam) Zend_Registry::set(naam,value)
Opdracht Maak een ini bestand, en plaats deze in de config map van de applicatie, maak een aantal instellingen aan Maak een productie deel en een test deel Lees bestand uit met behulp van Zend Framework Zet de inhoud van de ini op het scherm
Errorhandling Fouten Controller bestaat niet Actie bestaat niet Een exceptie (fout) wordt door een applicatie gegenereerd Opslaan van foutmeldingen is belangrijk (site debuggen) Duidelijke 404 pagina naar gebruiker
Errorhandling classErrorControllerextend Zend_Controller_Action { 	public functionerrorAction() { 		$errors = $this->_getParam(‘error_handler’); 		switch ($errors->type) { 			case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: 			case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: 			$this->getResponse ()->setRawHeader ( 'HTTP/1.1 404 Not Found' ) ; 			$this->view->titel = “404 Kan de paginanietvinden”; 			break; 		default: 			$this->view->titel = “Fout in de applicatie”; 			$exception = $errors->exception; 			break; 		} 		$this->view->message = $errors->exception; 	} }
Zend_Log Zend_Log is handig voor, de naam zegt het al, dingen te loggen! Kan een aantal delen bevatten: Log_Writer -> het uiteindelijke schrijven van de log Log_Filter -> data filteren voordat het weggeschreven wordt Log_Formatter -> formattering
Zend_Log Hoe werkt dit nu? $writer = new Zend_Log_Writer_Stream(‘logs/logbestand’); $logger = new Zend_Log($writer); Naar het log schrijven? $logger->log(‘Dit is een log bericht’, Zend_Log::INFO); Types: EMERG = 0; // Systeem onbruikbaar ALERT = 1; // Directe actie nodig CRIT = 2; // Kritische condities ERR = 3; // Error opgetredenWARN = 4; // Waarschuwing NOTICE = 5; // Melding INFO = 6; // Informatief DEBUG = 7; // Debug
Opdracht Maak een ErrorController welke alle informatie op kan slaan in een logbestand
Zend_View Templating, het onderdelen en inrichten van je site Gaat m.b.v. PHP Gebruik van short tags aangeraden door Zend <?= ?> Toekennen Escapen Meer mogelijkheden 	met Zend_Layout
Zend_View In de Controller worden de waarden toegekend aan de views Extra mogelijkheden Partials: fragmenten HTML Helpers: extra functionaliteiten bieden, functies toevoegen aan je view(s)
Zend_View  Partials roep je aan in je view(s) Gewoon een view binnen een view Vergelijkbaar met include Handig voor menu’s, footer’s e.d. Bestand /views/scripts/partials/header.phtml <title><?php echo $this->escape($this->title) ?></title> Bestand /views/scripts/index/index/html <?php echo $this->partial(‘partials/header.phtml’, array(‘title’=>’Titel van de pagina’));
Zend_View  Gebruik van helpers Kunnen eigen of door Zend gemaakte helpers zijn Standaard helpers in Zend: docType(‘XHTML1_STRICT’); url(array(‘var1’,’var2’,’var3’)); Form (formuliertjes bouwen, hierover meer later) Voorbeeldje: <?php echo $this->url(array(‘user’=>’JW’, 					’status’=>’programmer’)); ?> Uitkomst: /index/index/user/JW/status/programmer
Zend_Layout Menu Header Login Content
Zend_Layout Zend_View maar dan cooler File: /public/index.php (bootstrap) Zend_Layout::startMvc(); De view begint in /views/layout.phtml File: application/views/scripts/layout.phtml <?= $this->docType(‘XHTML1_STRICT’) ?> <html><head> <title><?= $this->headTitle() ?></title> 	<?= $this->headScript() ?> 	<?= $this->headStylesheet() ?> </head> <body> <divid=“menu”><?= $this->partial(‘menu.phtml’) ?></div> <divid=“content”><?= $this->layout()->content ?></div> <divid=“login”><?= $this->action(‘login', ‘loginboxje'); ?></div> </body> </html>

Mais conteúdo relacionado

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Cursus Zend Framework - 2

  • 1. Zend FrameworkAflevering 2 zendframework.bartj.com
  • 2. Later & Vandaag Later?? Adobe FLEX3 & AIR Case: Hondenbemiddeling Dierenbescherming Vandaag URL Formaat Zend_Config Zend_Log Zend_View Zend_Layout
  • 3. URL Formaat URL Formaat /index/index /tickets/index tickets is de controller index is de action /tickets/bekijkticket/ticketid/12345 tickets is de controller bekijkticket is de action ticketid is de naam/key van parameter1 12345 is de waarde van ticketid
  • 4. URL Formaat Bestand: application/controllers/IndexController.php classIndexControllerextends Zend_Controller_Action { public functionindexAction() { // Hier gaat het gebeuren } } Bestand: application/controllers/TicketsController.php classTicketsControllerextends Zend_Controller_Action { public functionindexAction() { // Index van de Tickets } public functionbekijkticketAction() { // Hier komt de code om tickets te bekijken } }
  • 5. Een klein stukje Zend_View Bestand: application/controllers/IndexController.php classIndexControllerextends Zend_Controller_Action { public functionindexAction() { $this->view->tekst = “hallooohallooo”; } } Bestand: application/views/scripts/index/index.phtml <html><head><title>Test van Hoi</title></head> <body> <?= $this->tekst ?> </body> </html>
  • 6. Zend_Config Zend_Config gebruik je om instellingen in te lezen en op te slaan Bijvoorbeeld MySQL Instellingen Kan via XML INI Naslagwerk http://framework.zend.com/manual/en/zend.config.html
  • 7. Zend_Config – INI File Inhoud INI File: [productie] hostname = www.bartj.com database.adapter = pdo_mysql database.params.hostname = mysql.bartj.com database.params.username = dbuser database.params.password = secret database.params.dbname = dbname ; test instellingen, rest overerven van productie [test:productie] database.params.hostname = test.mysql.bartj.com database.params.username = devuser database.params.password = devsecret
  • 8. Zend_Config – INI File - 2 $config = new Zend_Config_Ini(bestand, sectie, instellingen); v.b. $config = new Zend_Config_Ini(‘config.ini, ‘test’); Instellingen (Array) allowModifications -> true/false nestSeparator -> “.” (default)
  • 9. Zend_Registry Zend_Registry wordt gebruikt om informatie op te slaan die overal in de applicatie beschikbaar moet zijn Functies Zend_Registry::get(naam) Zend_Registry::set(naam,value)
  • 10. Opdracht Maak een ini bestand, en plaats deze in de config map van de applicatie, maak een aantal instellingen aan Maak een productie deel en een test deel Lees bestand uit met behulp van Zend Framework Zet de inhoud van de ini op het scherm
  • 11. Errorhandling Fouten Controller bestaat niet Actie bestaat niet Een exceptie (fout) wordt door een applicatie gegenereerd Opslaan van foutmeldingen is belangrijk (site debuggen) Duidelijke 404 pagina naar gebruiker
  • 12. Errorhandling classErrorControllerextend Zend_Controller_Action { public functionerrorAction() { $errors = $this->_getParam(‘error_handler’); switch ($errors->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: $this->getResponse ()->setRawHeader ( 'HTTP/1.1 404 Not Found' ) ; $this->view->titel = “404 Kan de paginanietvinden”; break; default: $this->view->titel = “Fout in de applicatie”; $exception = $errors->exception; break; } $this->view->message = $errors->exception; } }
  • 13. Zend_Log Zend_Log is handig voor, de naam zegt het al, dingen te loggen! Kan een aantal delen bevatten: Log_Writer -> het uiteindelijke schrijven van de log Log_Filter -> data filteren voordat het weggeschreven wordt Log_Formatter -> formattering
  • 14. Zend_Log Hoe werkt dit nu? $writer = new Zend_Log_Writer_Stream(‘logs/logbestand’); $logger = new Zend_Log($writer); Naar het log schrijven? $logger->log(‘Dit is een log bericht’, Zend_Log::INFO); Types: EMERG = 0; // Systeem onbruikbaar ALERT = 1; // Directe actie nodig CRIT = 2; // Kritische condities ERR = 3; // Error opgetredenWARN = 4; // Waarschuwing NOTICE = 5; // Melding INFO = 6; // Informatief DEBUG = 7; // Debug
  • 15. Opdracht Maak een ErrorController welke alle informatie op kan slaan in een logbestand
  • 16. Zend_View Templating, het onderdelen en inrichten van je site Gaat m.b.v. PHP Gebruik van short tags aangeraden door Zend <?= ?> Toekennen Escapen Meer mogelijkheden met Zend_Layout
  • 17. Zend_View In de Controller worden de waarden toegekend aan de views Extra mogelijkheden Partials: fragmenten HTML Helpers: extra functionaliteiten bieden, functies toevoegen aan je view(s)
  • 18. Zend_View Partials roep je aan in je view(s) Gewoon een view binnen een view Vergelijkbaar met include Handig voor menu’s, footer’s e.d. Bestand /views/scripts/partials/header.phtml <title><?php echo $this->escape($this->title) ?></title> Bestand /views/scripts/index/index/html <?php echo $this->partial(‘partials/header.phtml’, array(‘title’=>’Titel van de pagina’));
  • 19. Zend_View Gebruik van helpers Kunnen eigen of door Zend gemaakte helpers zijn Standaard helpers in Zend: docType(‘XHTML1_STRICT’); url(array(‘var1’,’var2’,’var3’)); Form (formuliertjes bouwen, hierover meer later) Voorbeeldje: <?php echo $this->url(array(‘user’=>’JW’, ’status’=>’programmer’)); ?> Uitkomst: /index/index/user/JW/status/programmer
  • 20. Zend_Layout Menu Header Login Content
  • 21. Zend_Layout Zend_View maar dan cooler File: /public/index.php (bootstrap) Zend_Layout::startMvc(); De view begint in /views/layout.phtml File: application/views/scripts/layout.phtml <?= $this->docType(‘XHTML1_STRICT’) ?> <html><head> <title><?= $this->headTitle() ?></title> <?= $this->headScript() ?> <?= $this->headStylesheet() ?> </head> <body> <divid=“menu”><?= $this->partial(‘menu.phtml’) ?></div> <divid=“content”><?= $this->layout()->content ?></div> <divid=“login”><?= $this->action(‘login', ‘loginboxje'); ?></div> </body> </html>