KEMBAR78
Tek13 - Creating Mobile Apps with PHP and Symfony | PDF
Creating Mobile Apps with
PHP & Symfony
Pablo Godel @pgodel
http://joind.in/8159
Tek13, Chicago, May 15 2013
Wednesday, May 15, 13
⁃ Born in Argentina, living in the US since 1999
⁃ PHP & Symfony developer
⁃ Founder of the original PHP mailing list in spanish
⁃ Master of the parrilla
⁃ Co-founder of ServerGrove
Who am I?!
Wednesday, May 15, 13
Wednesday, May 15, 13
Wednesday, May 15, 13
⁃ Founded ServerGrove Networks in 2005
⁃ Provider of web hosting specialized in PHP,
Symfony, ZendFramework, MongoDB and others
⁃ Servers in USA and Europe!
Who am I?!
Wednesday, May 15, 13
⁃ Very active open source supporter through code
contributions and usergroups/conference sponsoring
Community is our Teacher
Wednesday, May 15, 13
Why?
Mobile Apps - Why
Wednesday, May 15, 13
•More & more people have access to Internet through
mobile devices
•Devices are more powerful & versatile
•Internet access is faster and more reliable
•Users demand services and applications at all times &
and the go
•Don’t give advantages in an ultra-competitive market
•Your competition is already using it or implementing it
Mobile Apps - Why
Wednesday, May 15, 13
Some numbers...
Mobile Apps - Why
Wednesday, May 15, 13
•Estimated 6.5 billion mobile subscriptions globally (over
90%)
•1.7 billion mobile phones sold in 2012
•1 billion users in China alone
•321M subscriptions in the US (over 100%)
•Devices range from phone and tablets to door locks,
thermostats, etc.
Mobile Apps - Why
Wednesday, May 15, 13
How did we get here?
Mobile Apps - Why
Wednesday, May 15, 13
Let’s see some history...
Mobile Apps - History
Wednesday, May 15, 13
First commercial cellular network launched in
Japan )1G - first generation(
1979
Mobile Apps - History
Wednesday, May 15, 13
The “mobile” telephone
Motorola DynaTAC -
aka “The Boot”
cost: US$ 3995
weight:793g / 28 ounces
1983 Motorola DynaTAC
Mobile Apps - History
Wednesday, May 15, 13
Common Standard to connect networks and
apps
•WAP client
•Server sends WML (XML)
WAP - Wireless Application Protocol
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML
1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml" >
<wml>
<card id="main" title="First Card">
<p mode="wrap">This is a sample WML
page.</p>
</card>
</wml>
1997
Mobile Apps - History
Wednesday, May 15, 13
WAP/WML
Mobile Apps - History
Wednesday, May 15, 13
WAP/WML
Mobile Apps - History
Wednesday, May 15, 13
WAP/WML
Mobile Apps - History
Wednesday, May 15, 13
Developer:
WAP/WML
Mobile Apps - History
Wednesday, May 15, 13
User:
WAP/WML
Mobile Apps - History
Wednesday, May 15, 13
2007...
Mobile Apps - History
Wednesday, May 15, 13
•Revolutionized
the market of
mobile telephony
•Safari Web Client
iPhone2007
Mobile Apps - History
Wednesday, May 15, 13
iPhone App Store2007
Mobile Apps - History
Wednesday, May 15, 13
First Android Device2008
Mobile Apps - History
Wednesday, May 15, 13
iPad2010
Mobile Apps - History
Wednesday, May 15, 13
So what does all
this mean?
Mobile Apps - History
Wednesday, May 15, 13
The PC is not dead
Mobile Apps - History
The Mobile Generation
Wednesday, May 15, 13
The PC is not dead, yet?
The Mobile Generation
Mobile Apps - History
Wednesday, May 15, 13
Information is now consumed on phones and tablets
The Mobile Generation
Mobile Apps - History
Wednesday, May 15, 13
And this is just the beginning...
The Mobile Generation
Mobile Apps - History
Wednesday, May 15, 13
Symfony?
Mobile Apps - Symfony
Wednesday, May 15, 13
What is Symfony?
Mobile Apps - Symfony
Wednesday, May 15, 13
Definition by Fabien Potencier:
⁃ Symfony2 is a reusable set of standalone,
decoupled, and cohesive PHP components
that solve common web development
problems.
⁃ Based on these components, Symfony2 is
also a full-stack web framework.
http://fabien.potencier.org/article/49/what-is-symfony2
Mobile Apps - Symfony
Wednesday, May 15, 13
Silex
The PHP/‘Symfony’ micro-framework
http://silex.sensiolabs.org/
Mobile Apps - Symfony
Wednesday, May 15, 13
25 high quality
components
http://symfony.com/doc/current/components/index.html
Mobile Apps - Symfony
Wednesday, May 15, 13
• DependencyInjection
• EventDispatcher
• HttpFoundation
• DomCrawler
• ClassLoader
• CssSelector
• HttpKernel
• BrowserKit
• Templating
• Translation
• Serializer
• Validator
• Security
• Routing
• Console
• Process
• Config
• Finder
• Locale
• Yaml
• Form
Components:
GitHub: http://github.com/symfony
Mobile Apps - Symfony
Wednesday, May 15, 13
Proyects using Symfony2 components:
• Silex: BrowerKit, CssSelector, DomCrawler, EventDispatcher, HttpFoundation,
HttpKernel, Routing, Form, Translation, Validator
• Goutte: BrowserKit, DomCrawler, CssSelector, Process, ClassLoader, Finder
• Behat: Console, DependencyInjection, EventDispatcher, Finder, Yaml, Config,
Translation
• Doctrine2: Console, Yaml Propel2: Console, ClassLoader, Yaml
• PHPUnit: Yaml
• FLOW3: Yaml
• Midguard CMS: most of them in their next version?
• phpBB 4: most of them
• Drupal 8: ClassLoader, HttpFoundation, HttpKernel, and more
• EZ Publish
• Laravel
• Composer
• ...
Mobile Apps - Symfony
Wednesday, May 15, 13
Do you know or used
symfony 1.x?
Mobile Apps - Symfony
Wednesday, May 15, 13
Forget it...
Mobile Apps - Symfony
Wednesday, May 15, 13
The only thing in
common between
symfony 1.x & Symfony2
is the name...
Mobile Apps - Symfony
Wednesday, May 15, 13
OK... the web folder too...
Mobile Apps - Symfony
Wednesday, May 15, 13
Why Symfony?
Mobile Apps - Symfony
Wednesday, May 15, 13
•Provides solid base to build good HTTP &
RESTful APIs
•Twig makes it easy to build templates for
mobile devices
•Re-use code for different devices thanks to
templates, controllers and routing
Mobile Apps - Symfony
Wednesday, May 15, 13
1.Native applications
2.SMS applications & Voice applications
3.Web aplicaciones
4.Hybrid applications (mix native, web, others)
Mobile Apps - Types
Wednesday, May 15, 13
Native Applications
Mobile Apps - Types
Wednesday, May 15, 13
•iPhone - Objective-C
•Android - Java
•Windows Mobile - .NET
•Frameworks multi-platform
⁃ PhoneGap http://phonegap.com
⁃ rhomobile http://rhomobile.com
⁃ Appceledator http://appcelerator.com
⁃ Corona http://anscamobile.com/corona/
Mobile Apps - Native Apps
Wednesday, May 15, 13
Common uses:
•send emails & messages in general
•loading of profile data
•authentication & authorization
•chats
Mobile Apps - Native Apps
PHP does not run in these
devices but native apps need to
retrieve and store data from
servers.
Wednesday, May 15, 13
Some considerations:
•Design API (RESTful, HTTP, XML-RPC) early
on at the development cycle
•An API can be used for other types of clients
(ej. Desktop como Adobe AIR)
•Re-use controllers and use _format to
generate different content types (XML, JSON,
etc)
Mobile Apps - Native Apps
Wednesday, May 15, 13
Build APIs with Symfony2
- FOSRestBundle
https://packagist.org/packages/friendsofsymfony/rest-
bundle
- ApiDocBundle
https://packagist.org/packages/nelmio/api-doc-bundle
Mobile Apps - Native Apps
Build APIs with Silex
- responsible-service-provider
- silex-skeleton-rest
Wednesday, May 15, 13
Push Notifications
Server sends messages to mobile devices
- AppleApnPushBundle
- RMSPushNotificationsBundle
- DABSquaredPushNotificationsBundle
- ZendServiceGoogleGcm
- ZendServiceAppleApns
Mobile Apps - Native Apps
Wednesday, May 15, 13
SMS (and voice) Applications
Mobile Apps - SMS Apps
Wednesday, May 15, 13
Symfony can send/receive text messages
Common uses:
- Alerts
- Chats
- Electronic payments
- Ads
- Two-factor authentication
Mobile Apps - SMS Apps
Wednesday, May 15, 13
Mobile Apps - SMS Apps
Wednesday, May 15, 13
SMS Gateway providers:
•Twilio
•Nexmo
•Clickatell
•BulkSMS
Mobile Apps - SMS Apps
Wednesday, May 15, 13
MMS are multimedia messages with text,
images, video, audio.
Common uses:
- Photo processing
- Sending/scanning 2D barcodes
Mobile Apps - SMS/MMS Apps
https://github.com/endroid/QrCode
https://github.com/endroid/EndroidQrCodeBundle
https://github.com/mkoppanen/php-zbarcode
Wednesday, May 15, 13
Web Applications
Mobile Apps - Web Apps
Wednesday, May 15, 13
Mobile Apps - Web Apps
http://forecast.io
Wednesday, May 15, 13
Frameworks HTML / Javascript
• iui
http://code.google.com/p/iui/ (one of the first ones)
• JQuery Mobile
http://jquerymobile.com/ (Open source)
• JQTouch
http://jqtouch.com/ (Open source)
• DHTMLX Touch
http://dhtmlx.com/touch/ (Open source)
• The M Project
http://www.the-m-project.org/ (Open source)
• Sensa Touch
http://www.sencha.com/products/touch/
Mobile Apps - Web Apps
Wednesday, May 15, 13
Mobile Apps - Web Apps
jQuery Mobile
Wednesday, May 15, 13
Supports:
- IOS (iPhone/iPad)
- Android
- Blackberry
- Windows Phone
- palm webOS
- symbian
jQuery Mobile
Mobile Apps - Web Apps
Wednesday, May 15, 13
jQuery Mobile
Mobile Apps - Web Apps
Wednesday, May 15, 13
•Based on jQuery
•Light (40KB)
•HTML5
•Accesible (works on screen readers)
•Events, plugins, themes
•Lots of documentation
jQuery Mobile - Features
Mobile Apps - Web Apps
Wednesday, May 15, 13
•Page management
•Transitions
•Dialog windows
•Links and buttons
•Navigation bars
•Header / Footer
•Forms
•Lists
Mobile Apps - Web Apps
jQuery Mobile - Features
Wednesday, May 15, 13
jQuery Mobile - Page management
<body>
<!-- Start of first page -->
<div data-role="page" id="foo">
! <div data-role="content">!
! ! <p>I'm first in the source order so I'm shown as the page.
</p>!!
! ! <p>View internal page called <a href="#bar">bar</a></p>!
! </div><!-- /content -->
</div><!-- /page -->
</body>
Mobile Apps - Web Apps
Wednesday, May 15, 13
<body>
<!-- Start of first page -->
<div data-role="page" id="foo">
! <div data-role="content">!
! ! <p>View internal page called <a href="#bar">bar</a></p>!
! </div><!-- /content -->
</div><!-- /page -->
<!-- Start of second page -->
<div data-role="page" id="bar">
! <div data-role="content">!
! ! <p><a href="#foo">Back to foo</a></p>!
! </div><!-- /content -->
</div><!-- /page -->
</body>
Mobile Apps - Web Apps
jQuery Mobile - Page management
Wednesday, May 15, 13
jQuery Mobile - Transitions
<a href="foo.html" data-rel="dialog" data-transition="pop">Open dialog</a>
<a href="foo.html" data-rel="dialog" data-transition="slidedown">Open dialog</a>
<a href="foo.html" data-rel="dialog" data-transition="flip">Open dialog</a>
<a href="foo.html" data-rel="dialog" data-transition="fade">Open dialog</a>
Mobile Apps - Web Apps
Wednesday, May 15, 13
jQuery Mobile - Dialogs
Mobile Apps - Web Apps
Wednesday, May 15, 13
jQuery Mobile - Navigation bars
<div data-role="header" data-position="inline">
! <a href="index.html" data-icon="delete">Cancel</a>
! <h1>Edit Contact</h1>
! <a href="index.html" data-icon="check">Save</a>
</div>
Mobile Apps - Web Apps
Wednesday, May 15, 13
jQuery Mobile - Forms
Mobile Apps - Web Apps
Wednesday, May 15, 13
jQuery Mobile - Forms
Mobile Apps - Web Apps
Wednesday, May 15, 13
jQuery Mobile - Lists
Mobile Apps - Web Apps
Wednesday, May 15, 13
jQuery Mobile & Symfony
Mobile Apps - Web Apps
Wednesday, May 15, 13
Templates
Mobile Apps - Web Apps
Wednesday, May 15, 13
<!DOCTYPE html>
<html>
<head>
	

 <title>Podisum by ServerGrove</title>
	

 <meta name="viewport" content="width=device-width, initial-
scale=1">
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
layout.html.twig
Mobile Apps - Web Apps
Wednesday, May 15, 13
{% extends "layout.html.twig" %}
{% block content %}
<div data-role="page" id="home">
<div data-role="header">
<h1>Podisum</h1>
</div>
<div data-role="content">
<1-- ... -->
</div>
</div>
index.html.twig
Mobile Apps - Web Apps
Wednesday, May 15, 13
<div data-role="header" data-theme="b">
<h1>{{title}}</h1>
<a href="#home" data-icon="home" data-iconpos="notext" data-direction="reverse"
class="ui-btn-right jqm-home" data-ajax="false">Home</a>
</div>
header.mhtml.twig
Mobile Apps - Web Apps
Wednesday, May 15, 13
{% extends "layout.html.twig" %}
{% block content %}
{% include “header.html.twig’ %}
<div data-role="content">
<1-- ... -->
</div>
</div>
index.html.twig
Mobile Apps - Web Apps
Wednesday, May 15, 13
Routing
Mobile Apps - Web Apps
Wednesday, May 15, 13
home:
pattern: /
defaults: { _controller: DemoBundle:Default:index }
talks:
pattern: /talks.{_format}
defaults: { _controller: DemoBundle:Talk:index, _format: html }
requirements:
_format: html|xml|ics
talk:
pattern: /talk/{slug}
defaults: { _controller: DemoBundle:Talk:talk }
jQuery Mobile & Symfony / Routing
Mobile Apps - Web Apps
Wednesday, May 15, 13
Mobile Apps - Web Apps
jQuery Mobile & Symfony / Routing
home:
pattern: /m
defaults: { _controller: DemoBundle:Default:index,_format:mhtml }
talks:
pattern: /m/talks
defaults: { _controller: DemoBundle:Talk:index, _format:mhtml }
talk:
pattern: /m/talk/{slug}
defaults: { _controller: DemoBundle:Talk:talk, _format:mhtml }
Wednesday, May 15, 13
Mobile Apps - Web Apps
jQuery Mobile & Symfony / Routing
(option 2)
home:
pattern: /m
defaults: { _controller: DemoBundle:Default:index, mobile:true }
talks:
pattern: /m/talks
defaults: { _controller: DemoBundle:Talk:index, mobile:true }
talk:
pattern: /m/talk/{slug}
defaults: { _controller: DemoBundle:Talk:talk, mobile:true }
Wednesday, May 15, 13
m_home:
pattern: /m
defaults: { _controller: DemoBundle:Mobile:index }
Mobile Apps - Web Apps
jQuery Mobile & Symfony / Routing
(option 3)
Wednesday, May 15, 13
Controllers & Actions
Mobile Apps - Web Apps
Wednesday, May 15, 13
jQuery Mobile & Symfony / Controller & Action
public function indexAction()
{
$em = $this->get('doctrine')->getEntityManager();
// ...
$format = $this->get('request')->getRequestFormat();
return $this->render('DemoBundle:Default:index.'.$format.'.twig', array(
// ...
));
}
Mobile Apps - Web Apps
Wednesday, May 15, 13
Extras
Mobile Apps - Web Apps
•Detect Mobile devices
http://mobiledetect.net/
•Symfony2 + MobileDetectBundle
•Silex + MobileDetectServiceProvider
Wednesday, May 15, 13
Testing
Mobile Apps - Web Apps
Wednesday, May 15, 13
•Symfony2 functional tests for HTML pages
•For AJAX other testing methods may be used:
•Selenium RC
•Behat
Mobile Apps - Web Apps
Wednesday, May 15, 13
DEMOS !
Podisum:
http://github.com/pgodel/podisum
sunshinephp
http://m.sunshinephp.com/
Control Panel:
•https://control.servergrove.com/
•https://control.servergrove.com/m
login: demo@servergrove.com
password: demo
Mobile Apps - Web Apps
Wednesday, May 15, 13
Podisum http://github.com/pgodel/podisum
Generates summaries of Logstash events
Silex app
Twig templates
Mobile version
Mobile Apps - Web Apps
Wednesday, May 15, 13
Podisum
Apache access_log Logstash
Redis
Podisum redis-client
MongoDB
Podisum Silex App
Web Client
Mobile Apps - Web Apps
Wednesday, May 15, 13
Hybrid Applications
Mobile Apps - Hybrid Apps
Wednesday, May 15, 13
Applications that combine web, sms,
voice and native aspects
Framework PhoneGap
- Build apps with HTML & JavaScript
- Integrates with XCode
- Compiles app into native code
- Access to accelerometer, camera, geolocation,
notifications and more
Mobile Apps - Hybrid Apps
Wednesday, May 15, 13
Questions?
Mobile Apps
Wednesday, May 15, 13
Feedback Please:
http://joind.in/8159
Thank you!
Twitter: @pgodel
IRC Freenode: pgodel
Source: https://github.com/pgodel/podisum
Slides: http://slideshare.net/pgodel
Mobile Apps - Thanks!
Wednesday, May 15, 13

Tek13 - Creating Mobile Apps with PHP and Symfony

  • 1.
    Creating Mobile Appswith PHP & Symfony Pablo Godel @pgodel http://joind.in/8159 Tek13, Chicago, May 15 2013 Wednesday, May 15, 13
  • 2.
    ⁃ Born inArgentina, living in the US since 1999 ⁃ PHP & Symfony developer ⁃ Founder of the original PHP mailing list in spanish ⁃ Master of the parrilla ⁃ Co-founder of ServerGrove Who am I?! Wednesday, May 15, 13
  • 3.
  • 4.
  • 5.
    ⁃ Founded ServerGroveNetworks in 2005 ⁃ Provider of web hosting specialized in PHP, Symfony, ZendFramework, MongoDB and others ⁃ Servers in USA and Europe! Who am I?! Wednesday, May 15, 13
  • 6.
    ⁃ Very activeopen source supporter through code contributions and usergroups/conference sponsoring Community is our Teacher Wednesday, May 15, 13
  • 7.
    Why? Mobile Apps -Why Wednesday, May 15, 13
  • 8.
    •More & morepeople have access to Internet through mobile devices •Devices are more powerful & versatile •Internet access is faster and more reliable •Users demand services and applications at all times & and the go •Don’t give advantages in an ultra-competitive market •Your competition is already using it or implementing it Mobile Apps - Why Wednesday, May 15, 13
  • 9.
    Some numbers... Mobile Apps- Why Wednesday, May 15, 13
  • 10.
    •Estimated 6.5 billionmobile subscriptions globally (over 90%) •1.7 billion mobile phones sold in 2012 •1 billion users in China alone •321M subscriptions in the US (over 100%) •Devices range from phone and tablets to door locks, thermostats, etc. Mobile Apps - Why Wednesday, May 15, 13
  • 11.
    How did weget here? Mobile Apps - Why Wednesday, May 15, 13
  • 12.
    Let’s see somehistory... Mobile Apps - History Wednesday, May 15, 13
  • 13.
    First commercial cellularnetwork launched in Japan )1G - first generation( 1979 Mobile Apps - History Wednesday, May 15, 13
  • 14.
    The “mobile” telephone MotorolaDynaTAC - aka “The Boot” cost: US$ 3995 weight:793g / 28 ounces 1983 Motorola DynaTAC Mobile Apps - History Wednesday, May 15, 13
  • 15.
    Common Standard toconnect networks and apps •WAP client •Server sends WML (XML) WAP - Wireless Application Protocol <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml" > <wml> <card id="main" title="First Card"> <p mode="wrap">This is a sample WML page.</p> </card> </wml> 1997 Mobile Apps - History Wednesday, May 15, 13
  • 16.
    WAP/WML Mobile Apps -History Wednesday, May 15, 13
  • 17.
    WAP/WML Mobile Apps -History Wednesday, May 15, 13
  • 18.
    WAP/WML Mobile Apps -History Wednesday, May 15, 13
  • 19.
    Developer: WAP/WML Mobile Apps -History Wednesday, May 15, 13
  • 20.
    User: WAP/WML Mobile Apps -History Wednesday, May 15, 13
  • 21.
    2007... Mobile Apps -History Wednesday, May 15, 13
  • 22.
    •Revolutionized the market of mobiletelephony •Safari Web Client iPhone2007 Mobile Apps - History Wednesday, May 15, 13
  • 23.
    iPhone App Store2007 MobileApps - History Wednesday, May 15, 13
  • 24.
    First Android Device2008 MobileApps - History Wednesday, May 15, 13
  • 25.
    iPad2010 Mobile Apps -History Wednesday, May 15, 13
  • 26.
    So what doesall this mean? Mobile Apps - History Wednesday, May 15, 13
  • 27.
    The PC isnot dead Mobile Apps - History The Mobile Generation Wednesday, May 15, 13
  • 28.
    The PC isnot dead, yet? The Mobile Generation Mobile Apps - History Wednesday, May 15, 13
  • 29.
    Information is nowconsumed on phones and tablets The Mobile Generation Mobile Apps - History Wednesday, May 15, 13
  • 30.
    And this isjust the beginning... The Mobile Generation Mobile Apps - History Wednesday, May 15, 13
  • 31.
    Symfony? Mobile Apps -Symfony Wednesday, May 15, 13
  • 32.
    What is Symfony? MobileApps - Symfony Wednesday, May 15, 13
  • 33.
    Definition by FabienPotencier: ⁃ Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP components that solve common web development problems. ⁃ Based on these components, Symfony2 is also a full-stack web framework. http://fabien.potencier.org/article/49/what-is-symfony2 Mobile Apps - Symfony Wednesday, May 15, 13
  • 34.
  • 35.
  • 36.
    • DependencyInjection • EventDispatcher •HttpFoundation • DomCrawler • ClassLoader • CssSelector • HttpKernel • BrowserKit • Templating • Translation • Serializer • Validator • Security • Routing • Console • Process • Config • Finder • Locale • Yaml • Form Components: GitHub: http://github.com/symfony Mobile Apps - Symfony Wednesday, May 15, 13
  • 37.
    Proyects using Symfony2components: • Silex: BrowerKit, CssSelector, DomCrawler, EventDispatcher, HttpFoundation, HttpKernel, Routing, Form, Translation, Validator • Goutte: BrowserKit, DomCrawler, CssSelector, Process, ClassLoader, Finder • Behat: Console, DependencyInjection, EventDispatcher, Finder, Yaml, Config, Translation • Doctrine2: Console, Yaml Propel2: Console, ClassLoader, Yaml • PHPUnit: Yaml • FLOW3: Yaml • Midguard CMS: most of them in their next version? • phpBB 4: most of them • Drupal 8: ClassLoader, HttpFoundation, HttpKernel, and more • EZ Publish • Laravel • Composer • ... Mobile Apps - Symfony Wednesday, May 15, 13
  • 38.
    Do you knowor used symfony 1.x? Mobile Apps - Symfony Wednesday, May 15, 13
  • 39.
    Forget it... Mobile Apps- Symfony Wednesday, May 15, 13
  • 40.
    The only thingin common between symfony 1.x & Symfony2 is the name... Mobile Apps - Symfony Wednesday, May 15, 13
  • 41.
    OK... the webfolder too... Mobile Apps - Symfony Wednesday, May 15, 13
  • 42.
    Why Symfony? Mobile Apps- Symfony Wednesday, May 15, 13
  • 43.
    •Provides solid baseto build good HTTP & RESTful APIs •Twig makes it easy to build templates for mobile devices •Re-use code for different devices thanks to templates, controllers and routing Mobile Apps - Symfony Wednesday, May 15, 13
  • 44.
    1.Native applications 2.SMS applications& Voice applications 3.Web aplicaciones 4.Hybrid applications (mix native, web, others) Mobile Apps - Types Wednesday, May 15, 13
  • 45.
    Native Applications Mobile Apps- Types Wednesday, May 15, 13
  • 46.
    •iPhone - Objective-C •Android- Java •Windows Mobile - .NET •Frameworks multi-platform ⁃ PhoneGap http://phonegap.com ⁃ rhomobile http://rhomobile.com ⁃ Appceledator http://appcelerator.com ⁃ Corona http://anscamobile.com/corona/ Mobile Apps - Native Apps Wednesday, May 15, 13
  • 47.
    Common uses: •send emails& messages in general •loading of profile data •authentication & authorization •chats Mobile Apps - Native Apps PHP does not run in these devices but native apps need to retrieve and store data from servers. Wednesday, May 15, 13
  • 48.
    Some considerations: •Design API(RESTful, HTTP, XML-RPC) early on at the development cycle •An API can be used for other types of clients (ej. Desktop como Adobe AIR) •Re-use controllers and use _format to generate different content types (XML, JSON, etc) Mobile Apps - Native Apps Wednesday, May 15, 13
  • 49.
    Build APIs withSymfony2 - FOSRestBundle https://packagist.org/packages/friendsofsymfony/rest- bundle - ApiDocBundle https://packagist.org/packages/nelmio/api-doc-bundle Mobile Apps - Native Apps Build APIs with Silex - responsible-service-provider - silex-skeleton-rest Wednesday, May 15, 13
  • 50.
    Push Notifications Server sendsmessages to mobile devices - AppleApnPushBundle - RMSPushNotificationsBundle - DABSquaredPushNotificationsBundle - ZendServiceGoogleGcm - ZendServiceAppleApns Mobile Apps - Native Apps Wednesday, May 15, 13
  • 51.
    SMS (and voice)Applications Mobile Apps - SMS Apps Wednesday, May 15, 13
  • 52.
    Symfony can send/receivetext messages Common uses: - Alerts - Chats - Electronic payments - Ads - Two-factor authentication Mobile Apps - SMS Apps Wednesday, May 15, 13
  • 53.
    Mobile Apps -SMS Apps Wednesday, May 15, 13
  • 54.
  • 55.
    MMS are multimediamessages with text, images, video, audio. Common uses: - Photo processing - Sending/scanning 2D barcodes Mobile Apps - SMS/MMS Apps https://github.com/endroid/QrCode https://github.com/endroid/EndroidQrCodeBundle https://github.com/mkoppanen/php-zbarcode Wednesday, May 15, 13
  • 56.
    Web Applications Mobile Apps- Web Apps Wednesday, May 15, 13
  • 57.
    Mobile Apps -Web Apps http://forecast.io Wednesday, May 15, 13
  • 58.
    Frameworks HTML /Javascript • iui http://code.google.com/p/iui/ (one of the first ones) • JQuery Mobile http://jquerymobile.com/ (Open source) • JQTouch http://jqtouch.com/ (Open source) • DHTMLX Touch http://dhtmlx.com/touch/ (Open source) • The M Project http://www.the-m-project.org/ (Open source) • Sensa Touch http://www.sencha.com/products/touch/ Mobile Apps - Web Apps Wednesday, May 15, 13
  • 59.
    Mobile Apps -Web Apps jQuery Mobile Wednesday, May 15, 13
  • 60.
    Supports: - IOS (iPhone/iPad) -Android - Blackberry - Windows Phone - palm webOS - symbian jQuery Mobile Mobile Apps - Web Apps Wednesday, May 15, 13
  • 61.
    jQuery Mobile Mobile Apps- Web Apps Wednesday, May 15, 13
  • 62.
    •Based on jQuery •Light(40KB) •HTML5 •Accesible (works on screen readers) •Events, plugins, themes •Lots of documentation jQuery Mobile - Features Mobile Apps - Web Apps Wednesday, May 15, 13
  • 63.
    •Page management •Transitions •Dialog windows •Linksand buttons •Navigation bars •Header / Footer •Forms •Lists Mobile Apps - Web Apps jQuery Mobile - Features Wednesday, May 15, 13
  • 64.
    jQuery Mobile -Page management <body> <!-- Start of first page --> <div data-role="page" id="foo"> ! <div data-role="content">! ! ! <p>I'm first in the source order so I'm shown as the page. </p>!! ! ! <p>View internal page called <a href="#bar">bar</a></p>! ! </div><!-- /content --> </div><!-- /page --> </body> Mobile Apps - Web Apps Wednesday, May 15, 13
  • 65.
    <body> <!-- Start offirst page --> <div data-role="page" id="foo"> ! <div data-role="content">! ! ! <p>View internal page called <a href="#bar">bar</a></p>! ! </div><!-- /content --> </div><!-- /page --> <!-- Start of second page --> <div data-role="page" id="bar"> ! <div data-role="content">! ! ! <p><a href="#foo">Back to foo</a></p>! ! </div><!-- /content --> </div><!-- /page --> </body> Mobile Apps - Web Apps jQuery Mobile - Page management Wednesday, May 15, 13
  • 66.
    jQuery Mobile -Transitions <a href="foo.html" data-rel="dialog" data-transition="pop">Open dialog</a> <a href="foo.html" data-rel="dialog" data-transition="slidedown">Open dialog</a> <a href="foo.html" data-rel="dialog" data-transition="flip">Open dialog</a> <a href="foo.html" data-rel="dialog" data-transition="fade">Open dialog</a> Mobile Apps - Web Apps Wednesday, May 15, 13
  • 67.
    jQuery Mobile -Dialogs Mobile Apps - Web Apps Wednesday, May 15, 13
  • 68.
    jQuery Mobile -Navigation bars <div data-role="header" data-position="inline"> ! <a href="index.html" data-icon="delete">Cancel</a> ! <h1>Edit Contact</h1> ! <a href="index.html" data-icon="check">Save</a> </div> Mobile Apps - Web Apps Wednesday, May 15, 13
  • 69.
    jQuery Mobile -Forms Mobile Apps - Web Apps Wednesday, May 15, 13
  • 70.
    jQuery Mobile -Forms Mobile Apps - Web Apps Wednesday, May 15, 13
  • 71.
    jQuery Mobile -Lists Mobile Apps - Web Apps Wednesday, May 15, 13
  • 72.
    jQuery Mobile &Symfony Mobile Apps - Web Apps Wednesday, May 15, 13
  • 73.
    Templates Mobile Apps -Web Apps Wednesday, May 15, 13
  • 74.
    <!DOCTYPE html> <html> <head> <title>Podisumby ServerGrove</title> <meta name="viewport" content="width=device-width, initial- scale=1"> </head> <body> {% block content %} {% endblock %} </body> </html> layout.html.twig Mobile Apps - Web Apps Wednesday, May 15, 13
  • 75.
    {% extends "layout.html.twig"%} {% block content %} <div data-role="page" id="home"> <div data-role="header"> <h1>Podisum</h1> </div> <div data-role="content"> <1-- ... --> </div> </div> index.html.twig Mobile Apps - Web Apps Wednesday, May 15, 13
  • 76.
    <div data-role="header" data-theme="b"> <h1>{{title}}</h1> <ahref="#home" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home" data-ajax="false">Home</a> </div> header.mhtml.twig Mobile Apps - Web Apps Wednesday, May 15, 13
  • 77.
    {% extends "layout.html.twig"%} {% block content %} {% include “header.html.twig’ %} <div data-role="content"> <1-- ... --> </div> </div> index.html.twig Mobile Apps - Web Apps Wednesday, May 15, 13
  • 78.
    Routing Mobile Apps -Web Apps Wednesday, May 15, 13
  • 79.
    home: pattern: / defaults: {_controller: DemoBundle:Default:index } talks: pattern: /talks.{_format} defaults: { _controller: DemoBundle:Talk:index, _format: html } requirements: _format: html|xml|ics talk: pattern: /talk/{slug} defaults: { _controller: DemoBundle:Talk:talk } jQuery Mobile & Symfony / Routing Mobile Apps - Web Apps Wednesday, May 15, 13
  • 80.
    Mobile Apps -Web Apps jQuery Mobile & Symfony / Routing home: pattern: /m defaults: { _controller: DemoBundle:Default:index,_format:mhtml } talks: pattern: /m/talks defaults: { _controller: DemoBundle:Talk:index, _format:mhtml } talk: pattern: /m/talk/{slug} defaults: { _controller: DemoBundle:Talk:talk, _format:mhtml } Wednesday, May 15, 13
  • 81.
    Mobile Apps -Web Apps jQuery Mobile & Symfony / Routing (option 2) home: pattern: /m defaults: { _controller: DemoBundle:Default:index, mobile:true } talks: pattern: /m/talks defaults: { _controller: DemoBundle:Talk:index, mobile:true } talk: pattern: /m/talk/{slug} defaults: { _controller: DemoBundle:Talk:talk, mobile:true } Wednesday, May 15, 13
  • 82.
    m_home: pattern: /m defaults: {_controller: DemoBundle:Mobile:index } Mobile Apps - Web Apps jQuery Mobile & Symfony / Routing (option 3) Wednesday, May 15, 13
  • 83.
    Controllers & Actions MobileApps - Web Apps Wednesday, May 15, 13
  • 84.
    jQuery Mobile &Symfony / Controller & Action public function indexAction() { $em = $this->get('doctrine')->getEntityManager(); // ... $format = $this->get('request')->getRequestFormat(); return $this->render('DemoBundle:Default:index.'.$format.'.twig', array( // ... )); } Mobile Apps - Web Apps Wednesday, May 15, 13
  • 85.
    Extras Mobile Apps -Web Apps •Detect Mobile devices http://mobiledetect.net/ •Symfony2 + MobileDetectBundle •Silex + MobileDetectServiceProvider Wednesday, May 15, 13
  • 86.
    Testing Mobile Apps -Web Apps Wednesday, May 15, 13
  • 87.
    •Symfony2 functional testsfor HTML pages •For AJAX other testing methods may be used: •Selenium RC •Behat Mobile Apps - Web Apps Wednesday, May 15, 13
  • 88.
  • 89.
    Podisum http://github.com/pgodel/podisum Generates summariesof Logstash events Silex app Twig templates Mobile version Mobile Apps - Web Apps Wednesday, May 15, 13
  • 90.
    Podisum Apache access_log Logstash Redis Podisumredis-client MongoDB Podisum Silex App Web Client Mobile Apps - Web Apps Wednesday, May 15, 13
  • 91.
    Hybrid Applications Mobile Apps- Hybrid Apps Wednesday, May 15, 13
  • 92.
    Applications that combineweb, sms, voice and native aspects Framework PhoneGap - Build apps with HTML & JavaScript - Integrates with XCode - Compiles app into native code - Access to accelerometer, camera, geolocation, notifications and more Mobile Apps - Hybrid Apps Wednesday, May 15, 13
  • 93.
  • 94.
    Feedback Please: http://joind.in/8159 Thank you! Twitter:@pgodel IRC Freenode: pgodel Source: https://github.com/pgodel/podisum Slides: http://slideshare.net/pgodel Mobile Apps - Thanks! Wednesday, May 15, 13