PFA (PHP for Android) is a project that lets you write native Android apps in php. In this talk you'll learn how to install and use this project to develop on your phone with php.
7. Android
• built on top of a linux
kernel
• native libc (Bionic):
0.5 * sizeof(GNU libC)
• runtime (Dalvik VM) +
system libs
• application framework
• Java!
8. How can we make php run
on Android?
1. static compilation with Glibc (over
7MB)... fat!
2. linked to Bionic: smaller (~2MB), but
tweaks needed
9. How can we make php run
on Android?
3. SL4A to the rescue!
10. SL4A – scripting layer for
Android
• Google project, led by
Damon Kohler
• Open Source
• exposes Android API
• quite active
12. PHP for Android project
• led by Iván Mosquera,
software engineer at Irontec
(the people behind IronPython
and other OS projects)
• Open Source
• Started in 2009
• php-for-android on Google
Groups
13. PFA: installation
The PFA apk just installs
other components:
• php_rX.zip:
– php binary
• php_scripts_rX.zip
– scripts and PFAf
• php_extras_rX.zip
• Android.php + php.ini
23. PFA: access phone features
<?php
require_once('Android.php');
$droid = new Android();
$droid>viewContacts();
24. PFA: access phone features
Many more features
available; API full list:
http://j.mp/9btqUG
Examples: smsSend, sendEmail,
cameraCapturePicture, viewHTML,
bluetoothConnect, contactsGet,
viewMap... (perhaps not *everything*
available yet)
29. PFA: including remote code
<?php
require_once('Android.php');
$droid = new Android();
include('http://www.wyrd.it/
droid.php.txt');
<?php
$droid>makeToast("There's a
starman waiting in the sky!");
remote.php
droid.php.txt
31. PFA: including remote code
include('http://www.wyrd.it/
droid.php.txt');
Secure
Handy
?
This is here for testing purposes ONLY!
32. PFA: including remote code
Don't forget that PFA,
although yet useable in
many respects, is still
alpha software.
In the future we'll be
able to distribute scripts
in apk format, without
using allow_url_fopen
35. PFAf: PFA framework
Base php class: ScriptAbstract; apps
extend this class and implement init()
States-based: put on a stack the next
action you want to execute
function currentAction(){
...
$this>setNextAction('next');
}
function nextAction() { ... }
37. PFA wants you!
You can help by writing
scripts and sharing
them:
http://www.phpforandroid.net/scripts
...and there are good examples there!
Take a look at the wi-fi scanner and the
web server ;)