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 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 Slide

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

    View Slide

  4. Going Mobile?

    View 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 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 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 Slide

  8. Mobile Practices

    View 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 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 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 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 Slide

  13. Designing Service Objects

    View Slide

  14. 14
    Aspects of a Service Layer

    View 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 Slide

  16. 16
    Quick and Dirty Sample Service

    View 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 Slide

  18. 18
    Quick and Dirty Sample Entity

    View 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 Slide

  20. 20
    Quick and Dirty Data Mapper Example

    View 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 Slide

  22. ZF2 Integration

    View 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 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 Slide

  25. 25
    Changing the Default Suffix

    View 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 Slide

  27. 27
    Changing the template

    View 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 Slide

  29. 29
    Changing the Controller

    View 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 Slide

  31. 31
    Routing to Mobile

    View 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 Slide

  33. 33
    Web Services Example

    View Slide

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

    View Slide

  35. 35
    Abstract Restful Controller!

    View 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 Slide

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

    View Slide

  38. 38
    10,000 Foot View of APNS

    View Slide

  39. 39
    10,000 Foot View of Windows Push

    View Slide

  40. 40
    Using Zend_Mobile_Push_Apns

    View Slide

  41. 41
    Using Zend_Mobile_Push_Apns Feedback

    View Slide

  42. 42
    Using Zend_Mobile_Push_Gcm

    View Slide

  43. 43
    Using Zend_Mobile_Push_Mpns Raw Messages

    View Slide

  44. 44
    Using Zend_Mobile_Push_Mpns Toast Messages

    View Slide

  45. 45
    Using Zend_Mobile_Push_Mpns Tile Messages

    View Slide

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

    View 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 Slide