PHP goes mobile
Upcoming SlideShare
Loading in...5
×
 

PHP goes mobile

on

  • 7,789 views

Sviluppo di applicazioni web mobile con Zend Framework

Sviluppo di applicazioni web mobile con Zend Framework

Statistics

Views

Total Views
7,789
Views on SlideShare
2,666
Embed Views
5,123

Actions

Likes
4
Downloads
32
Comments
0

10 Embeds 5,123

http://www.zimuel.it 5089
http://abtasty.com 14
http://translate.googleusercontent.com 12
http://www.verious.com 2
http://www.zimuel.it. 1
http://paper.li 1
http://prlog.ru 1
https://twitter.com 1
http://citiface_new.local 1
http://www.linkedin.com 1
More...

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

PHP goes mobile PHP goes mobile Presentation Transcript

  • Sviluppo di applicazioni webmobile con Zend FrameworkEnrico ZimuelSenior PHP Engineer, Zend TechnologiesZend Framework Core TeamPHP goes mobile, 13 Aprile 2012http://mobilephp.grusp.org/ © All rights reserved. Zend Technologies, Inc.
  • Chi sono ● Software Engineer dal 1996 (1984?) ▶ Assembly, Basic, C/C++, Java, Perl, PHP ● PHP Engineer e Software Architect presso Zend Technologies dal 2008 ● Zend Framework Core Team dal 2011 ● Research Programmer presso lInformatics Institute dellUniversità di Amsterdam ● Co-autore del libro “PHP best practices” FAG edizioni (in corso di pubblicazione) © All rights reserved. Zend Technologies, Inc.
  • Web mobile vs. Native App © All rights reserved. Zend Technologies, Inc.
  • Web mobile vs. Native App Web mobile Native App Accesso al limitato totale dispositivo Velocità buona ottima Costi sviluppo bassi medio/alti Tecnologia open si a volte Ricavi 100% dipende Approvazione nessuna dipende Tempi di rilascio immediati 1-2 settimane Linguaggio di HTML e qualsiasi dipende programmazione altro (esempio PHP) © All rights reserved. Zend Technologies, Inc.
  • Web mobile vs. Native App (2) “People never cared about the Web vs. apps and devices . . . They want free stuff, entertainment, and services when they want them, and on the device they have in front of them” Fonte: Pew Internet Project (Marzo, 2012) © All rights reserved. Zend Technologies, Inc.
  • Web mobile con ZF © All rights reserved. Zend Technologies, Inc.
  • Zend Framework● Framework PHP per lo sviluppo di applicazioni web ▶ > 10 milioni di download ▶ > 500 sviluppatori ▶ > 10 milioni hits su Google● Open source, licenza basata su new BSD● Versioni: 1.11.11 (PHP 5.2) e 2.0.0.beta3 (PHP 5.3+)● Sito del progetto: http://framework.zend.com● © Zend Technologies Ltd. © All rights reserved. Zend Technologies, Inc.
  • Zend Technologies● Zend Technologies Ltd, the PHP Company● Fondata nel 1999 da Andi Gutmans e Zeev Suraski, gli sviluppatori del PHP 3.0● Quartier generale nella Silicon Valley a Cupertino (USA)● Uffici in: Francia, Germania, India, Irlanda, Israele, Italia● © PHP Engine 2 (linterprete del PHP)● Sito: http://www.zend.com © All rights reserved. Zend Technologies, Inc.
  • Componenti ZF per il web mobile● Zend_Http_UserAgent ▶ BrowsCap ▶ Tera-WURFL ▶ DeviceAtlas● Context Switching● Zend_Mobile ▶ Disponibile dalla versione 1.12 di ZF © All rights reserved. Zend Technologies, Inc.
  • BrowsCap● Funzione get_browser() del PHP● Configurazione: ▶ Download del file browscap.ini dal sito del progetto Browser Capabilities: http://browsers.garykeith.com/downloads ▶ Configurare php.ini con la direttiva: browscap=/path/to/browscap.ini © All rights reserved. Zend Technologies, Inc.
  • Tera-WURFL● Tera-WURFL è una libreria in PHP e un database in MySQL/MSSQL/MongoDB di informazioni su device● Download: http://dbapi.scientiamobile.com © All rights reserved. Zend Technologies, Inc.
  • DeviceAtlas● Libreria disponibile per diversi linguaggi (PHP, Java, .NET, Python, Ruby) per il riconoscimento di mobile device● Download: http://deviceatlas.com/resourcecentre/get+started/enterprise+api © All rights reserved. Zend Technologies, Inc.
  • Zend_Http_UserAgent● Utilizzato per identificare il device dellutente● Utilizzabile in diversi punti di unapplicazione ZF ▶ Plugin (bootstrap) ▶ Controller ▶ View © All rights reserved. Zend Technologies, Inc.
  • Zend_Http_UserAgent (2)● Plugin (bootstrap) ▶ $bootstrap = Zend_Controller_Front::getInstance()->getParam(bootstrap); $userAgent = $bootstrap->getResource(useragent);● Controller ▶ $bootstrap = $this->getInvokeArg(bootstrap); $userAgent = $bootstrap->getResource(useragent);● View ▶ $userAgent = $this->userAgent(); © All rights reserved. Zend Technologies, Inc.
  • Alcuni metodi dellUserAgent● getDevice()● getBrowserType()● getAllFeatures()● hasFlashSupport()● hasPdfSupport()● hasPhoneNumber()● httpsSupport()● getMaxImageHeight()● getMaxImageWidth()● ... © All rights reserved. Zend Technologies, Inc.
  • Context switching● ContextSwitching è un action helper che consente di definire risposte differenti a seconda del contesto (della richiesta)● E di solito utilizzato nei web services per differenziare la risposta (ad esempio Json o XML)● Permette di definire contesti custom ▶ Aggiungere dei suffissi alle viste ▶ Modificare lheader HTTP ▶ Definire delle callback © All rights reserved. Zend Technologies, Inc.
  • Esempioclass Application_Plugin_Mobile extends Zend_Controller_Plugin_Abstract{ public function dispatchLoopStartup( Zend_Controller_Request_Abstract $request) { $contextSwitch = Zend_Controller_Action_HelperBroker::getStaticHelper(ContextSwitch); $contextSwitch->clearContexts() ->setContext(iphone, array( suffix => iphone, headers => array( Content-Type => text/html;Charset=UTF-8), )) ->setContext(html, array( suffix => html, headers => array( Content-Type => text/html;Charset=UTF-8), )) ->setAutoDisableLayout(false) ->setDefaultcontext(html) ->initContext(); © All rights reserved. Zend Technologies, Inc.
  • Esempio (2) $bootstrap = Zend_Controller_Front::getInstance()->getParam(bootstrap); $userAgent = $bootstrap->getResource(useragent); switch($userAgent->getDevice()->getFeature(device)) { case iphone: $request->setParam(format,iphone); break; default: $request->setParam(format,html); } }} © All rights reserved. Zend Technologies, Inc.
  • Esempio (3) class IndexController extends Zend_Controller_Action { public function init() { $this->_helper->contextSwitch() ->addActionContext(index, iphone) ->initContext(); } … } index.phtml index.iphone.phtml View © All rights reserved. Zend Technologies, Inc.
  • Zend_Mobile● Zend_Mobile_Push ▶ Invio di notifiche push verso specifici vendor ● APNS (iTouch/iPad/iPhone) ● C2DM (Google Android) ● MPNS (Windows Phone) © All rights reserved. Zend Technologies, Inc.
  • Esempio$message = new Zend_Mobile_Push_Message_Apns();$message->setAlert(Zend Mobile Push Example);$message->setBadge(1);$message->setSound(default);$message->setId(time());$message->setToken(ABCDEF0123456789);$apns = new Zend_Mobile_Push_Apns();$apns->setCertificate(/path/to/provisioning-certificate.pem);// if you have a passphrase on your certificate:// $apns->setCertificatePassphrase(foobar);... © All rights reserved. Zend Technologies, Inc.
  • Esempio (2)try { $apns->connect(Zend_Mobile_Push_Apns::SERVER_SANDBOX_URI);} catch (Zend_Mobile_Push_Exception_ServerUnavailable $e) {// you can either attempt to reconnect here or try again later exit(1);} catch (Zend_Mobile_Push_Exception $e) { echo APNS Connection Error: . $e->getMessage(); exit(1);}try { $apns->send($message);} catch (Zend_Mobile_Push_Exception_InvalidToken $e) { echo $e->getMessage();} catch (Zend_Mobile_Push_Exception $e) { echo $e->getMessage();}$apns->close(); © All rights reserved. Zend Technologies, Inc.
  • Domande? © All rights reserved. Zend Technologies, Inc.
  • Grazie!Per maggiori informazioni:http://framework.zend.com/ © All rights reserved. Zend Technologies, Inc.