Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

34
Replace with a graphic 5.5” Tall & 4.3” Wide ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. 1 Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship Mihai Corlan Platform Evangelist, Adobe PHP GeekMeet 2009, Cluj

Transcript of Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

Page 1: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

White Master

Replace with a graphic

5.5” Tall & 4.3” Wide

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 1

Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

Mihai Corlan Platform Evangelist, Adobe

PHP GeekMeet 2009, Cluj

Page 2: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 2

About me

•  Platform Evangelist, member of the Adobe’s European team

•  Used to be a Flex Builder engineer (Java Desktop SWT, Eclipse

Platform)

•  Used to be a web developer (PHP, ColdFusion, DHTML, JS, MySQL,

Sybase…)

•  ~9 years experience with web related technologies

•  I write articles, I do presentations, and I code

Page 3: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 3

Today’s Agenda

•  What is RIA and why RIA is a good thing

•  What is Flex

•  What is Adobe AIR

•  Why AIR applications?

•  Flex/AIR and PHP

•  Q & A

Page 4: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 4

What matters?

Experience Matters!

Page 5: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 5

What matters?

USER Experience Matters!

Page 6: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 6

A shoe story…

More than 2.000 years experience in producing shoes.

We can produce them really cheap.

20 Euro a pair, maybe?

Page 7: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 7

A shoe story…

More than 2.000 years experience in producing shoes.

We can produce them really cheap.

20 Euro a pair, maybe?

Wrong! Because of better user experience, people women are willing to pay 100+ euro!

Better design, limited edition = better user experience = greater value

Page 8: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 8

What is RIA?

MAINFRAME

RE

AC

H

Local

Global

RICH Text UI Integrated media GUI

CLIENT/SERVER

WEB APPLICATIONS

2004

1992

1998

RICH INTERNET APPLICATIONS

Page 9: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 9

Demos time!

Let’s see what it can be done with the Flash Platform!

Flash Player

Page 10: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 10

What is Flex?

  Flex is just another way to create a Flash application

Flash Player

Page 11: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 11

What is Flex?

  Flex SDK   2 languages

  MXML   ActionScript 3

  Compilers   Rich Component Library   Debuggers

Flex SDK

Flex Class Library

MXML ActionScript

Debuggers

Page 12: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 12

What is Flex?

  Flex SDK   2 languages

  MXML   ActionScript 3

  Compilers   Rich Component Library   Debuggers

  Flex Builder IDE   Eclipse Plug-in or turn-key install

  Accelerates Design and Development

  Design view and code view

Flex Builder IDE

Flex SDK

Flex Class Library

MXML ActionScript

Debuggers

Flash Player

Page 13: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 13

What is Flex?

  Flex SDK   2 languages

  MXML   ActionScript 3

  Compilers   Rich Component Library   Debuggers

  Flex Builder IDE   Eclipse Plug-in or turn-key install

  Accelerates Design and Development

  Design view and code view

Flex Builder IDE

Flex SDK

Flex Class Library

MXML ActionScript

Debuggers

Compile

Browser

Flash Player

Page 14: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 14

What is AIR?

Adobe® AIR™ lets developers use their existing web development skills in HTML,

AJAX, Flash and Flex to build and deploy rich Internet applications to the desktop

on Windows, Mac or Linux.

Page 15: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 15

Adobe AIR Application Stack

Cross-OS Application

Integrated Rendering

Integrated DOMs & Scripting

Flash

Flex ActionScript XML Audio Video

HTML

PDF

HTML

HTML JavaScript XML CSS

Flash

PDF

Adobe AIR APIs

Mac, Windows, Linux & Device OS

File System Access

Network Detection Notifications Application

Update Drag and Drop

Local Database ...

Page 16: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 16

RIAs can be limited by the browser

Page 17: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 17

#1 – No offline access

Page 18: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 18

#2 – Constrained within the browser chrome

Browser chrome & application chrome con"ict

Page 19: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 19

#3 – Common desktop interactions not possible

Drag & drop not possible

Page 20: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 20

#4 – Local system access limited

File interaction restricted by browser sandbox

Page 21: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 21

#5 – Updates only delivered when browser is open

Alerts only visible when browser open

Page 22: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 22

Why RIAs on the desktop

Persistent connection

Desktop functionality Data access Efficient development

Branded experiences

Page 23: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 23

AIR capabilities

•  Native window types (normal, utility, lightweight)

•  Support for multiple monitors

•  Native Menu support (App, window, dock, system tray, context)

•  Full access to the local #le system (read/create/delete)

•  Encrypted Local Storage

•  Local SQLite databases, including encrypted

•  Drag and Drop

•  Clipboard (read/write)

•  Network activity monitor

Page 24: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 24

Communication between Flex and PHP server

“I think this is the beginning of a beautiful friendship!”

Flex & AIR on the client, PHP on the server.

Web browser FLEX Apps

Desktop AIR Apps

Server PHP

REST Services

Web Services

Remoting

Page 25: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 25

Are there any Flex/AIR apps with PHP out there?

AIR & Flex apps with PHP backend:

http://corlan.org/"exair-and-php-apps/

Page 26: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 26

What tools to use?

For Flex and PHP and Eclipse based solution:

•  Flex Builder + PDT

•  Flex Builder + Zend Studio

Advantages:

•  You can create combined Flex and PHP or AIR and PHP projects

•  That helps you with deploying, and debugging

Page 27: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 27

Debugging

Debugging Flex applications:

1.  Use a log function on the server, and save the var_dump of the PHP

variables in a "at #le

2.  Use Charles proxy sniffer, you can inspect the traffic between client

and server

3.  Use Flex Builder and Zend Studio debuggers

Page 28: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 28

How does remoting work?

MyClass {

getData() { … } saveData($myVO) {…}

}

Flex/AIR Client PHP Server AMF3

Page 29: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 29

How does remoting work?

RemoteObject

getData(); saveData(myVO);

MyClass {

getData() { … } saveData($myVO) {…}

}

Client calls MyClass->getData()

Flex/AIR Client PHP Server AMF3

Page 30: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 30

How does remoting work?

RemoteObject

getData(); saveData(myVO);

MyClass {

getData() { … } saveData($myVO) {…}

}

Client calls MyClass->getData()

Flex/AIR Client PHP Server

MyVO {

public $id; public $name;

}

MyVO {

public var id:int; public var name:String;

}

Automatic conversion between PHP and ActionScript class

AMF3

Page 31: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 31

How does remoting work?

RemoteObject

getData(); saveData(myVO);

MyClass {

getData() { … } saveData($myVO) {…}

}

Client calls MyClass->getData()

Flex/AIR Client PHP Server

MyVO {

public $id; public $name;

}

MyVO {

public var id:int; public var name:String;

}

Server sends an array of MyVO objects

Automatic conversion between PHP and ActionScript class

Client calls RemoteObject.saveData(myVO) MyClass->saveData($myVO)

AMF3

Page 32: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 32

REST vs. AMF?

http://www.jamesward.com/census/

Page 33: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 33

PHP and AMF

There are four libraries for doing remoting with PHP classes:

1.  Zend AMF – part of the Zend Framework

2.  AMFPHP

3.  WebORB for PHP (remoting and data messaging – publisher/subscriber)

4.  SabreAMF

Page 34: Flex, Adobe AIR, and PHP: the beginning of a beautiful friendship

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. 34

Thank you!

Download Flex Builder: http://www.adobe.com/go/flex_trial AIR: http://www.adobe.com/go/air AIR Adobe Developer Center: http://www.adobe.com/devnet/air/ Download Tour de Flex: http://flex.org/tour Learn Flex in one week: http://www.adobe.com/devnet/flex/videotraining/

Mihai Corlan

Blog: http://corlan.org

E-mail: [email protected]