Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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.

Mike Willbanks

August 28, 2018
Tweet

More Decks by Mike Willbanks

Other Decks in Technology

Transcript

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

    View full-size slide

  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…

    View full-size slide

  3. 3
    • Going Mobile?
    • Mobile Practices
    • Service Design
    • ZF2 Integration
    Agenda

    View full-size slide

  4. Going Mobile?

    View full-size slide

  5. 5
    A Definition
    Form Factors of web sites need to change; luckily we’re not in
    the days of these phones anymore!

    View full-size slide

  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!

    View full-size slide

  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

    View full-size slide

  8. Mobile Practices

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  13. Designing Service Objects

    View full-size slide

  14. 14
    Aspects of a Service Layer

    View full-size slide

  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

    View full-size slide

  16. 16
    Quick and Dirty Sample Service

    View full-size slide

  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

    View full-size slide

  18. 18
    Quick and Dirty Sample Entity

    View full-size slide

  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

    View full-size slide

  20. 20
    Quick and Dirty Data Mapper Example

    View full-size slide

  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

    View full-size slide

  22. ZF2 Integration

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  25. 25
    Changing the Default Suffix

    View full-size slide

  26. 26
    • Changing the template is sometimes a valid area
     The content you have is fine but the template is too much.
    Changing Templates

    View full-size slide

  27. 27
    Changing the template

    View full-size slide

  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

    View full-size slide

  29. 29
    Changing the Controller

    View full-size slide

  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

    View full-size slide

  31. 31
    Routing to Mobile

    View full-size slide

  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

    View full-size slide

  33. 33
    Web Services Example

    View full-size slide

  34. 34
    • If you do RESTful implementations for your API
     AbstractRestfulController OR RestfulController
    What about Restful implementations?

    View full-size slide

  35. 35
    Abstract Restful Controller!

    View full-size slide

  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

    View full-size slide

  37. 37
    10,000 Foot View of GCM
    Registration
    Request
    Registration ID
    Store ID
    Send Messages
    Push Messages

    View full-size slide

  38. 38
    10,000 Foot View of APNS

    View full-size slide

  39. 39
    10,000 Foot View of Windows Push

    View full-size slide

  40. 40
    Using Zend_Mobile_Push_Apns

    View full-size slide

  41. 41
    Using Zend_Mobile_Push_Apns Feedback

    View full-size slide

  42. 42
    Using Zend_Mobile_Push_Gcm

    View full-size slide

  43. 43
    Using Zend_Mobile_Push_Mpns Raw Messages

    View full-size slide

  44. 44
    Using Zend_Mobile_Push_Mpns Toast Messages

    View full-size slide

  45. 45
    Using Zend_Mobile_Push_Mpns Tile Messages

    View full-size slide

  46. 46
    • There are several strategies to mobile
    • Each has their pros and cons
    • Utilize which methods work best for you.
    Recap

    View full-size slide

  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?

    View full-size slide