Zendcon 2012 - Going Mobile with ZF2

Zendcon 2012 - Going Mobile with ZF2

This session goes through the several tactics that you may take from a ZF2 point of view and how you might incorporate going mobile with your website.

753abf3aed0f744b24efda893b67ff43?s=128

Mike Willbanks

August 28, 2018
Tweet

Transcript

  1. Going Mobile with ZF2 Mike Willbanks | Barnes & Noble

  2. 2 •  Talk  Slides will be posted after the talk.

    •  Me  Sr. Web Architect Manager at NOOK Developer  Open Source Contributor  Where you can find me: •  Twitter: mwillbanks G+: Mike Willbanks •  IRC (freenode): mwillbanks Blog: http://blog.digitalstruct.com •  GitHub: https://github.com/mwillbanks Housekeeping…
  3. 3 • Going Mobile? • Mobile Practices • Service Design • ZF2 Integration Agenda

  4. Going Mobile?

  5. 5 A Definition Form Factors of web sites need to

    change; luckily we’re not in the days of these phones anymore!
  6. 6 Mobile is everywhere! • From laptops, tablets and smartphones  Who

    has all 3? • Typing is more difficult on tablets and smartphones  Unless of course you have a keyboard for your tablet. • Everyone wants to be able to access anything, anytime, anywhere.  And you need to let them!
  7. 7 Websites, Apps and more oh my! • Implementations…  There is

    an app for that! • Native? HTML5? • iOS, Android, Windows Mobile, Blackberry?  There is a website for that too! • Main website • Mobile website
  8. Mobile Practices

  9. 9 • Do I  Build out one size fits all?  Build

    out a mobile version? • Do I use responsive techniques? • Do I change layouts? • Do I change the information?  Build out an app? • HTML 5 or Native? • Use a framework? Titanium, Phonegap, etc? So many different approaches
  10. 10 • Designing a single website for multiple form factors • Generally

    done by using a responsive framework  Twitter Bootstrap does this J • Pros  Generally faster to develop.  Eases layout issues to get something to production quickly. • Cons  Not fully mobilized  Still downloads items potentially not needed. Responsive Design
  11. 11 • Designing a single website for multiple form factors • Individual

    pages are different based on device and/or type. • Pros  Generally a better user experience. • Cons  Additional work to create separate layouts and views.  May still have backend work that you are not leveraging.  May contain routes that are unnecessary for a mobile experience. Separate Layouts and Views
  12. 12 • Designing a single website for multiple form factors • Individual

    pages are different based on device and/or type. • Pros  Completely customizable website and fully separate. • Cons  Far more work.  Must customize how your traffic may flow. Separate Site
  13. Designing Service Objects

  14. 14 Aspects of a Service Layer

  15. 15 • Satisfies a Business function  Function broken into Tasks • Easy

    consumption by your application • Allows vast re-use and more generic implementations • Decoupled to represent more or less a single item • Application logic becomes more encompassed  Filtering  Validation  Transactions / Interactions between Domain Models A Service
  16. 16 Quick and Dirty Sample Service

  17. 17 • A domain model is a representative entity of “something”

    that solves a domain problem. • The entity is NOT explicitly tied to your database. • The entity essentially contains getters and setters for properties and potentially some behaviors. Domain Models aka Entities
  18. 18 Quick and Dirty Sample Entity

  19. 19 • A data mapper handles the communication between the data

    source and the population of an domain model.  In a ZF context this is generally fetching data from Zend\Db \TableGateway. • Extremely flexible and easily handles if the underlying data changes.  Alternatively; when you now have separate tables that still can represent the same domain model. Data Mapper
  20. 20 Quick and Dirty Data Mapper Example

  21. 21 • Persistence… you need to store it somewhere! • Data may

    come from several places…  File System  Web Service  NoSQL DB  Relational DB • If you utilize an ORM this is also where it would live. • If you’re looking for a sweet library  http://contain-project.org/contain  Tweet @andrewkandels Data Store
  22. ZF2 Integration

  23. 23 • Several different techniques  WURFL – based on capabilities • Free

    BUT non-open source license. • Learn more about the PHP API: http://wurfl.sourceforge.net/php_index.php  preg_match – based on user agent only\  Likely to be a better way • Just not coded yet. Mobile User Detection
  24. 24 • To achieve separate views between mobile users and non-

    mobile users  Change the default suffix of the template path stack. Changing Default Suffixes
  25. 25 Changing the Default Suffix

  26. 26 • Changing the template is sometimes a valid area  The

    content you have is fine but the template is too much. Changing Templates
  27. 27 Changing the template

  28. 28 • Do you need to do specific mobile work in

    a controller?  Same type of thing as before; except we can change the view if need be. Manually within a Controller
  29. 29 Changing the Controller

  30. 30 • Sometimes you may want a mobile specific website  m.yourhost.com

    • Incorporating into a separate module • Can do through routing! Completely Separate Website
  31. 31 Routing to Mobile

  32. 32 • You remember the service objects from earlier? • Implementing API’s

    based off of your service classes can be easy! • ZF Built-ins  SOAP Server  JSONRPC Server  XMLRPC Server Attaching Services
  33. 33 Web Services Example

  34. 34 • If you do RESTful implementations for your API  AbstractRestfulController

    OR RestfulController What about Restful implementations?
  35. 35 Abstract Restful Controller!

  36. 36 • Leverage Zend_Mobile from ZF1 (1.12)  Hopefully going to port

    over soon to ZendService components. • Quick Primer into looking at Push Notifications Push Notifications
  37. 37 10,000 Foot View of GCM Registration Request Registration ID

    Store ID Send Messages Push Messages
  38. 38 10,000 Foot View of APNS

  39. 39 10,000 Foot View of Windows Push

  40. 40 Using Zend_Mobile_Push_Apns

  41. 41 Using Zend_Mobile_Push_Apns Feedback

  42. 42 Using Zend_Mobile_Push_Gcm

  43. 43 Using Zend_Mobile_Push_Mpns Raw Messages

  44. 44 Using Zend_Mobile_Push_Mpns Toast Messages

  45. 45 Using Zend_Mobile_Push_Mpns Tile Messages

  46. 46 • There are several strategies to mobile • Each has their

    pros and cons • Utilize which methods work best for you. Recap
  47. 47 •  These slides will be posted to SlideShare &

    SpeakerDeck.   SpeakerDeck: http://speakerdeck.com/u/mwillbanks   Slideshare: http://www.slideshare.net/mwillbanks   Twitter: mwillbanks   G+: Mike Willbanks   IRC (freenode): mwillbanks   Blog: http://blog.digitalstruct.com   GitHub: https://github.com/mwillbanks Questions?