SlideShare a Scribd company logo
1 of 31
PHP for Android: PHP scripting on Android
$self ● Kinn Coelho Julião – Gerente de projetos - RPM – Instrutor PHP – 4Linux/DRC – PHP for Android Brasil project founder. – @kinncj
Index ● Android. – Introdução – Arquitetura ● PHP no Android ● Compilação do PHP ● SL4A & PhpForAndroid. ● Exemplo: script “WhereAmI”. – PFAf ● Desenvolvimento e compartilhamento ● Perguntas
Android ● Mobile OS.  ● Opensource. ● 200.000 /dia ● ->  tablet
Android
Android
PHP on Android ● Android “é” Linux. ● Então, deve funcionar – É claro que sim... ● ARM cross compiling. ● Método 1 (fécil): – Compilação estática gnu libc (> 7MB)
PHP on Android ● Caminho não tão fácil: – Lincado a libc Bionic. ● Bionic: libc do Android – BSD. – sizeof(gnu_libc) * 0.5 – Documentação incompleta. ● PHP no Android. – Php-cli sapi – Agcc  – Tweaks devido o bionic. – =~ 2MB – Sockets, json.
The problem ● API php -> OK ● UI? (php-gtk?) ● Chamadas? ● Mensagens? ● Localização? ● Sensores? ● ... ● Mobile web.
The solution ● Google project (Damon Kohler), opensource. ● SL4A (Scripting Layer For Android)  ● Android app (APK). ● Camada para linguagens Scripts ● Expõe a API Android ● Realmente ativos, liberam sempre
The solution ● Oficialmente suporta as linguagens: – Python. – Perl. – Ruby. – Lua... ● Para cada interpretador -> APK installer.
The PFA project ● ● @phpforandroid ● SL4A PHP support. ● APK. ● Android PHP binary. ● Framework. ● Free software. Http://www.phpforandroid.net
The PFA project ● http://www.php4android.com.br ● HowTo's ● News ● PT-BR Support
APKs ● APKs: – SL4A – PFA ● SL4A detecta PFA (Intenção de filtro)
PHP for Android ● Installer (that's all folks): – PHP bin. ● php_rX.zip – Scripts ● php_scripts_rX.zip – Misc ● Android.php ● php.ini ● php_extras_rX.zip
SL4A ● Gerenciamento dos Scripts. ● Android Facades. ● Instalação do interpretador.
PHP for Android & SL4A ● 0.1 (ASE r26 unofficial, php 5.3.3rc2) ● 0.2 (SL4A_r0, php 5.3.3rc3) ● 0.3 (SL4A_r2+, php 5.3.3)
The Android class <?php include 'Android.php'; $droid = new Android(); public function __call($name, $args) { return $this->rpc($name, $args); } Json RPC
The Android class public function rpc($method, $args) { $data = array( 'id'=>$this->_id,  'method'=>$method, 'params'=>$args ); $request =  json_encode ($data) . “”; $sent = socket_write($this->_socket, $request,  strlen($request));
The Android class $response = socket_read($this->_socket, 1024,  PHP_NORMAL_READ) or die(&quot;Could not read  input&quot;);  $this->_id++; $result =  json_decode ($response); return  array ('id' => $result-> id , 'result' => $result-> result , 'error' => $result-> error ); }
The Android class <?php require “Android.php”; $droid = new Android(); $droid->viewContacts();
“ WhereAmI” script ● Localização ● Email building (link do maps).
“ WhereAmI” script $droid-> startLocating (); – Received: {&quot;id&quot;:24,&quot;method&quot;:&quot;startLocating&quot;,&quot;params&quot;:[]} – Sent: {&quot;error&quot;:null,&quot;id&quot;:24,&quot;result&quot;:null} $location = $droid-> readLocation (); – Received: {&quot;id&quot;:25,&quot;method&quot;:&quot;readLocation&quot;,&quot;params&quot;:[]} – Sent: {&quot;error&quot;:null,&quot;id&quot;:25,&quot;result&quot;:{&quot;network&quot;: {&quot;provider&quot;:&quot;network&quot;,&quot;time&quot;:1288215482448,&quot;longitud e&quot;:- 46.6167,&quot;latitude&quot;:-23.5333,&quot;speed&quot;:0,&quot;accuracy&quot; :76,&quot;altitude&quot;:0}}}
“ WhereAmI” script $droid-> stopLocating (); – Received: {&quot;id&quot;:26,&quot;method&quot;:&quot;stopLocating&quot;,&quot;params&quot;:[]} – Sent: {&quot;error&quot;:null,&quot;id&quot;:26,&quot;result&quot;:null} $longitude =  $location[&quot;result&quot;]->network->longitude; $latitude =  $location[&quot;result&quot;]->network->latitude; $mapLink = sprintf('http://maps.google.com/maps? q=%s,%s', $latitude, $longitude);
“ WhereAmI” script $data .= &quot;Google maps : $mapLink&quot;; $droid-> sendEmail ('', 'To aqui Rapeize ', $data ); – Received: {&quot;id&quot;:29,&quot;method&quot;:&quot;sendEmail&quot;,&quot;params&quot;: [&quot;&quot;,&quot;Donde estoy&quot;,&quot;admin_area : Sao Paulo feature_name : 3 sub_admin_area : Sao Paulo  postal_code : 04002033 locality : Sao Paulo  thoroughfare : 4Linux  country_code : BR country_name : Brazil  Google Maps: http:maps.google.commaps? q=-23.5333, -46.6167&quot;]} – Sent: {&quot;error&quot;:null,&quot;id&quot;:29,&quot;result&quot;:null}
PFAf ● Maciej Wilgucki @wilgucki ● Framework disponível desde o PFA 0.3. ● Estenda a parte Abstrada, implementa o init ● Organiza seu script com estados ● function FooAction() { .... $this->setNextAction('bar');
PFAf Início Créditos Informação
Development environment ● SL4A... – Emulador, adb. ● [allow_url_fopen, allow_url_include] -> ON – testnow.php – testcache.php ● Remote scripting.
Script sharing ● SL4A scripts folder. ● Barcode (<4296 chars) ● Script on APK: – Template project -> customize. – ANT
Roadmap ● SL4A – API extended. ● GUI... – Bugfixes. ● PFA – Sqlite,... phpize. – supporting SL4A releases.
????? Perguntas? Logo @Workoholics_

More Related Content

What's hot

Fuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP SeasidesFuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP SeasidesOWASPSeasides
 
prototype::signatures
prototype::signaturesprototype::signatures
prototype::signaturesclkao
 
Resful Trinity Code One - San Francisco
Resful Trinity Code One - San FranciscoResful Trinity Code One - San Francisco
Resful Trinity Code One - San FranciscoIvan Junckes Filho
 
Last Month in PHP - June through Mid-July 2017
Last Month in PHP - June through Mid-July 2017Last Month in PHP - June through Mid-July 2017
Last Month in PHP - June through Mid-July 2017Eric Poe
 
Chasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and DocumentationChasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and DocumentationRoberto Cortez
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y GradleAntonio Mas
 
Metasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OSMetasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OSKiwamu Okabe
 
really really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesreally really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesGiulio De Donato
 
GraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionGraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionRoberto Cortez
 
Flutter beers and pizza
Flutter beers and pizzaFlutter beers and pizza
Flutter beers and pizzaJon Durán
 
Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)Peter Kofler
 
Special Subject 1+2: RoR 1
Special Subject 1+2: RoR 1Special Subject 1+2: RoR 1
Special Subject 1+2: RoR 1Stefan Fodor
 

What's hot (17)

Fuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP SeasidesFuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP Seasides
 
prototype::signatures
prototype::signaturesprototype::signatures
prototype::signatures
 
Resful Trinity Code One - San Francisco
Resful Trinity Code One - San FranciscoResful Trinity Code One - San Francisco
Resful Trinity Code One - San Francisco
 
Tdd presentation
Tdd presentationTdd presentation
Tdd presentation
 
Last Month in PHP - June through Mid-July 2017
Last Month in PHP - June through Mid-July 2017Last Month in PHP - June through Mid-July 2017
Last Month in PHP - June through Mid-July 2017
 
Chasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and DocumentationChasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and Documentation
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y Gradle
 
Metasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OSMetasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OS
 
Go, meet Lua
Go, meet LuaGo, meet Lua
Go, meet Lua
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
Terraform & IaC - Nam CXN
Terraform & IaC - Nam CXNTerraform & IaC - Nam CXN
Terraform & IaC - Nam CXN
 
really really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesreally really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfaces
 
GraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionGraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices Solution
 
Flutter beers and pizza
Flutter beers and pizzaFlutter beers and pizza
Flutter beers and pizza
 
Jedi knight
Jedi knightJedi knight
Jedi knight
 
Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)
 
Special Subject 1+2: RoR 1
Special Subject 1+2: RoR 1Special Subject 1+2: RoR 1
Special Subject 1+2: RoR 1
 

Viewers also liked

Overzicht gebruik sociale media verkiezingen 2012 Verenigde Staten
Overzicht gebruik sociale media verkiezingen 2012 Verenigde StatenOverzicht gebruik sociale media verkiezingen 2012 Verenigde Staten
Overzicht gebruik sociale media verkiezingen 2012 Verenigde StatenHanneke van Stokkom
 
Mot so bai_toan_khac_ve_thoi_gian
Mot so bai_toan_khac_ve_thoi_gianMot so bai_toan_khac_ve_thoi_gian
Mot so bai_toan_khac_ve_thoi_gianTuân Ngô
 
Azotea de finca mackey
Azotea de finca mackeyAzotea de finca mackey
Azotea de finca mackeyTonytorovaser
 
Que Lado Del Cerebro Usas?
Que Lado Del Cerebro Usas?Que Lado Del Cerebro Usas?
Que Lado Del Cerebro Usas?Ardwenna --
 
Aydinlatma direkleri temel temel detaylari
Aydinlatma direkleri temel  temel detaylariAydinlatma direkleri temel  temel detaylari
Aydinlatma direkleri temel temel detaylariesregroup
 
GTMS. Atenció a la dependència DAP Costa de Ponent
GTMS. Atenció a la dependència DAP Costa de PonentGTMS. Atenció a la dependència DAP Costa de Ponent
GTMS. Atenció a la dependència DAP Costa de PonentInstitut Català de la Salut
 
팀원과 정기면담, 도란도란 사례공유
팀원과 정기면담, 도란도란 사례공유팀원과 정기면담, 도란도란 사례공유
팀원과 정기면담, 도란도란 사례공유Doyoung Kwon
 
WebRTC, another Web?
WebRTC, another Web?WebRTC, another Web?
WebRTC, another Web?Hui Fan
 
RoboCV Module 5: Contours using OpenCV
RoboCV Module 5: Contours using OpenCVRoboCV Module 5: Contours using OpenCV
RoboCV Module 5: Contours using OpenCVroboVITics club
 
Bai tap phan ung oxi hoa lop 10
Bai tap phan ung oxi hoa lop 10Bai tap phan ung oxi hoa lop 10
Bai tap phan ung oxi hoa lop 10Tuân Ngô
 
Vnx.su vesta-trud
Vnx.su vesta-trudVnx.su vesta-trud
Vnx.su vesta-trudladaman
 
TADHack London, Igor Pavlov, Showcase, When your fingers get tired… jump into...
TADHack London, Igor Pavlov, Showcase, When your fingers get tired… jump into...TADHack London, Igor Pavlov, Showcase, When your fingers get tired… jump into...
TADHack London, Igor Pavlov, Showcase, When your fingers get tired… jump into...Alan Quayle
 
Vnx.su lada 2170 tpудоемкость
Vnx.su lada 2170 tpудоемкостьVnx.su lada 2170 tpудоемкость
Vnx.su lada 2170 tpудоемкостьgsx1
 
Vnx.su особенности суд ваз-21126
Vnx.su особенности суд ваз-21126Vnx.su особенности суд ваз-21126
Vnx.su особенности суд ваз-21126ladaman
 
Student management system
Student management systemStudent management system
Student management systemStudent
 
TADHack London, Distillate, Roderick Hodgson & Alex Francois, Telestax, Dialo...
TADHack London, Distillate, Roderick Hodgson & Alex Francois, Telestax, Dialo...TADHack London, Distillate, Roderick Hodgson & Alex Francois, Telestax, Dialo...
TADHack London, Distillate, Roderick Hodgson & Alex Francois, Telestax, Dialo...Alan Quayle
 

Viewers also liked (20)

Overzicht gebruik sociale media verkiezingen 2012 Verenigde Staten
Overzicht gebruik sociale media verkiezingen 2012 Verenigde StatenOverzicht gebruik sociale media verkiezingen 2012 Verenigde Staten
Overzicht gebruik sociale media verkiezingen 2012 Verenigde Staten
 
Proyecto Facebook – DimensióN ParticipacióN
Proyecto Facebook – DimensióN ParticipacióNProyecto Facebook – DimensióN ParticipacióN
Proyecto Facebook – DimensióN ParticipacióN
 
Benaulim india
Benaulim indiaBenaulim india
Benaulim india
 
Mot so bai_toan_khac_ve_thoi_gian
Mot so bai_toan_khac_ve_thoi_gianMot so bai_toan_khac_ve_thoi_gian
Mot so bai_toan_khac_ve_thoi_gian
 
Azotea de finca mackey
Azotea de finca mackeyAzotea de finca mackey
Azotea de finca mackey
 
Que Lado Del Cerebro Usas?
Que Lado Del Cerebro Usas?Que Lado Del Cerebro Usas?
Que Lado Del Cerebro Usas?
 
Aydinlatma direkleri temel temel detaylari
Aydinlatma direkleri temel  temel detaylariAydinlatma direkleri temel  temel detaylari
Aydinlatma direkleri temel temel detaylari
 
Behaviour modelling
Behaviour modellingBehaviour modelling
Behaviour modelling
 
Npc force weekly 21 may 25 may 2012
Npc force weekly 21 may   25 may 2012Npc force weekly 21 may   25 may 2012
Npc force weekly 21 may 25 may 2012
 
GTMS. Atenció a la dependència DAP Costa de Ponent
GTMS. Atenció a la dependència DAP Costa de PonentGTMS. Atenció a la dependència DAP Costa de Ponent
GTMS. Atenció a la dependència DAP Costa de Ponent
 
팀원과 정기면담, 도란도란 사례공유
팀원과 정기면담, 도란도란 사례공유팀원과 정기면담, 도란도란 사례공유
팀원과 정기면담, 도란도란 사례공유
 
WebRTC, another Web?
WebRTC, another Web?WebRTC, another Web?
WebRTC, another Web?
 
RoboCV Module 5: Contours using OpenCV
RoboCV Module 5: Contours using OpenCVRoboCV Module 5: Contours using OpenCV
RoboCV Module 5: Contours using OpenCV
 
Bai tap phan ung oxi hoa lop 10
Bai tap phan ung oxi hoa lop 10Bai tap phan ung oxi hoa lop 10
Bai tap phan ung oxi hoa lop 10
 
Vnx.su vesta-trud
Vnx.su vesta-trudVnx.su vesta-trud
Vnx.su vesta-trud
 
TADHack London, Igor Pavlov, Showcase, When your fingers get tired… jump into...
TADHack London, Igor Pavlov, Showcase, When your fingers get tired… jump into...TADHack London, Igor Pavlov, Showcase, When your fingers get tired… jump into...
TADHack London, Igor Pavlov, Showcase, When your fingers get tired… jump into...
 
Vnx.su lada 2170 tpудоемкость
Vnx.su lada 2170 tpудоемкостьVnx.su lada 2170 tpудоемкость
Vnx.su lada 2170 tpудоемкость
 
Vnx.su особенности суд ваз-21126
Vnx.su особенности суд ваз-21126Vnx.su особенности суд ваз-21126
Vnx.su особенности суд ваз-21126
 
Student management system
Student management systemStudent management system
Student management system
 
TADHack London, Distillate, Roderick Hodgson & Alex Francois, Telestax, Dialo...
TADHack London, Distillate, Roderick Hodgson & Alex Francois, Telestax, Dialo...TADHack London, Distillate, Roderick Hodgson & Alex Francois, Telestax, Dialo...
TADHack London, Distillate, Roderick Hodgson & Alex Francois, Telestax, Dialo...
 

Similar to Php4android TDC 2011

Phpforandroid en
Phpforandroid enPhpforandroid en
Phpforandroid enivmos
 
Openshift: Deployments for the rest of us
Openshift: Deployments for the rest of usOpenshift: Deployments for the rest of us
Openshift: Deployments for the rest of usAnurag Patel
 
Plack on SL4A in Yokohama.pm #8
Plack on SL4A in Yokohama.pm #8Plack on SL4A in Yokohama.pm #8
Plack on SL4A in Yokohama.pm #8Yoshiki Kurihara
 
Profiling PHP & Javascript
Profiling PHP & JavascriptProfiling PHP & Javascript
Profiling PHP & JavascriptDave Ross
 
DrupalCon Europe 2020 Low Code
DrupalCon Europe 2020 Low CodeDrupalCon Europe 2020 Low Code
DrupalCon Europe 2020 Low CodeAlejandro Moreno
 
How to learn to code
How to learn to codeHow to learn to code
How to learn to codeAmit Kumar
 
Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015Hiroshi Ota
 
Angular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entrepriseAngular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entrepriseLINAGORA
 
Build and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 MinsBuild and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 MinsJeff Hull
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Mark Niebergall
 
Raspberry Pi + ROS
Raspberry Pi + ROSRaspberry Pi + ROS
Raspberry Pi + ROSArnoldBail
 
Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022QAware GmbH
 
TypeScript no Grupo Bandeirantes
TypeScript no Grupo BandeirantesTypeScript no Grupo Bandeirantes
TypeScript no Grupo BandeirantesMVP Microsoft
 
gRPC or Rest, why not both?
gRPC or Rest, why not both?gRPC or Rest, why not both?
gRPC or Rest, why not both?Mohammad Murad
 
Exploring Raspberry Pi
Exploring Raspberry PiExploring Raspberry Pi
Exploring Raspberry PiLentin Joseph
 

Similar to Php4android TDC 2011 (20)

Phpforandroid en
Phpforandroid enPhpforandroid en
Phpforandroid en
 
Openshift: Deployments for the rest of us
Openshift: Deployments for the rest of usOpenshift: Deployments for the rest of us
Openshift: Deployments for the rest of us
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 
Plack on SL4A in Yokohama.pm #8
Plack on SL4A in Yokohama.pm #8Plack on SL4A in Yokohama.pm #8
Plack on SL4A in Yokohama.pm #8
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
 
Profiling PHP & Javascript
Profiling PHP & JavascriptProfiling PHP & Javascript
Profiling PHP & Javascript
 
DrupalCon Europe 2020 Low Code
DrupalCon Europe 2020 Low CodeDrupalCon Europe 2020 Low Code
DrupalCon Europe 2020 Low Code
 
How to learn to code
How to learn to codeHow to learn to code
How to learn to code
 
Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015
 
Angular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entrepriseAngular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entreprise
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
PHP as a Service TDC2019
PHP as a Service TDC2019PHP as a Service TDC2019
PHP as a Service TDC2019
 
Build and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 MinsBuild and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 Mins
 
From Perl To Elixir
From Perl To ElixirFrom Perl To Elixir
From Perl To Elixir
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
 
Raspberry Pi + ROS
Raspberry Pi + ROSRaspberry Pi + ROS
Raspberry Pi + ROS
 
Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022
 
TypeScript no Grupo Bandeirantes
TypeScript no Grupo BandeirantesTypeScript no Grupo Bandeirantes
TypeScript no Grupo Bandeirantes
 
gRPC or Rest, why not both?
gRPC or Rest, why not both?gRPC or Rest, why not both?
gRPC or Rest, why not both?
 
Exploring Raspberry Pi
Exploring Raspberry PiExploring Raspberry Pi
Exploring Raspberry Pi
 

Recently uploaded

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Php4android TDC 2011

  • 1. PHP for Android: PHP scripting on Android
  • 2. $self ● Kinn Coelho Julião – Gerente de projetos - RPM – Instrutor PHP – 4Linux/DRC – PHP for Android Brasil project founder. – @kinncj
  • 3. Index ● Android. – Introdução – Arquitetura ● PHP no Android ● Compilação do PHP ● SL4A & PhpForAndroid. ● Exemplo: script “WhereAmI”. – PFAf ● Desenvolvimento e compartilhamento ● Perguntas
  • 4. Android ● Mobile OS. ● Opensource. ● 200.000 /dia ● -> tablet
  • 7. PHP on Android ● Android “é” Linux. ● Então, deve funcionar – É claro que sim... ● ARM cross compiling. ● Método 1 (fécil): – Compilação estática gnu libc (> 7MB)
  • 8. PHP on Android ● Caminho não tão fácil: – Lincado a libc Bionic. ● Bionic: libc do Android – BSD. – sizeof(gnu_libc) * 0.5 – Documentação incompleta. ● PHP no Android. – Php-cli sapi – Agcc – Tweaks devido o bionic. – =~ 2MB – Sockets, json.
  • 9. The problem ● API php -> OK ● UI? (php-gtk?) ● Chamadas? ● Mensagens? ● Localização? ● Sensores? ● ... ● Mobile web.
  • 10. The solution ● Google project (Damon Kohler), opensource. ● SL4A (Scripting Layer For Android) ● Android app (APK). ● Camada para linguagens Scripts ● Expõe a API Android ● Realmente ativos, liberam sempre
  • 11. The solution ● Oficialmente suporta as linguagens: – Python. – Perl. – Ruby. – Lua... ● Para cada interpretador -> APK installer.
  • 12. The PFA project ● ● @phpforandroid ● SL4A PHP support. ● APK. ● Android PHP binary. ● Framework. ● Free software. Http://www.phpforandroid.net
  • 13. The PFA project ● http://www.php4android.com.br ● HowTo's ● News ● PT-BR Support
  • 14. APKs ● APKs: – SL4A – PFA ● SL4A detecta PFA (Intenção de filtro)
  • 15. PHP for Android ● Installer (that's all folks): – PHP bin. ● php_rX.zip – Scripts ● php_scripts_rX.zip – Misc ● Android.php ● php.ini ● php_extras_rX.zip
  • 16. SL4A ● Gerenciamento dos Scripts. ● Android Facades. ● Instalação do interpretador.
  • 17. PHP for Android & SL4A ● 0.1 (ASE r26 unofficial, php 5.3.3rc2) ● 0.2 (SL4A_r0, php 5.3.3rc3) ● 0.3 (SL4A_r2+, php 5.3.3)
  • 18. The Android class <?php include 'Android.php'; $droid = new Android(); public function __call($name, $args) { return $this->rpc($name, $args); } Json RPC
  • 19. The Android class public function rpc($method, $args) { $data = array( 'id'=>$this->_id, 'method'=>$method, 'params'=>$args ); $request = json_encode ($data) . “”; $sent = socket_write($this->_socket, $request, strlen($request));
  • 20. The Android class $response = socket_read($this->_socket, 1024, PHP_NORMAL_READ) or die(&quot;Could not read input&quot;); $this->_id++; $result = json_decode ($response); return array ('id' => $result-> id , 'result' => $result-> result , 'error' => $result-> error ); }
  • 21. The Android class <?php require “Android.php”; $droid = new Android(); $droid->viewContacts();
  • 22. “ WhereAmI” script ● Localização ● Email building (link do maps).
  • 23. “ WhereAmI” script $droid-> startLocating (); – Received: {&quot;id&quot;:24,&quot;method&quot;:&quot;startLocating&quot;,&quot;params&quot;:[]} – Sent: {&quot;error&quot;:null,&quot;id&quot;:24,&quot;result&quot;:null} $location = $droid-> readLocation (); – Received: {&quot;id&quot;:25,&quot;method&quot;:&quot;readLocation&quot;,&quot;params&quot;:[]} – Sent: {&quot;error&quot;:null,&quot;id&quot;:25,&quot;result&quot;:{&quot;network&quot;: {&quot;provider&quot;:&quot;network&quot;,&quot;time&quot;:1288215482448,&quot;longitud e&quot;:- 46.6167,&quot;latitude&quot;:-23.5333,&quot;speed&quot;:0,&quot;accuracy&quot; :76,&quot;altitude&quot;:0}}}
  • 24. “ WhereAmI” script $droid-> stopLocating (); – Received: {&quot;id&quot;:26,&quot;method&quot;:&quot;stopLocating&quot;,&quot;params&quot;:[]} – Sent: {&quot;error&quot;:null,&quot;id&quot;:26,&quot;result&quot;:null} $longitude = $location[&quot;result&quot;]->network->longitude; $latitude = $location[&quot;result&quot;]->network->latitude; $mapLink = sprintf('http://maps.google.com/maps? q=%s,%s', $latitude, $longitude);
  • 25. “ WhereAmI” script $data .= &quot;Google maps : $mapLink&quot;; $droid-> sendEmail ('', 'To aqui Rapeize ', $data ); – Received: {&quot;id&quot;:29,&quot;method&quot;:&quot;sendEmail&quot;,&quot;params&quot;: [&quot;&quot;,&quot;Donde estoy&quot;,&quot;admin_area : Sao Paulo feature_name : 3 sub_admin_area : Sao Paulo postal_code : 04002033 locality : Sao Paulo thoroughfare : 4Linux country_code : BR country_name : Brazil Google Maps: http:maps.google.commaps? q=-23.5333, -46.6167&quot;]} – Sent: {&quot;error&quot;:null,&quot;id&quot;:29,&quot;result&quot;:null}
  • 26. PFAf ● Maciej Wilgucki @wilgucki ● Framework disponível desde o PFA 0.3. ● Estenda a parte Abstrada, implementa o init ● Organiza seu script com estados ● function FooAction() { .... $this->setNextAction('bar');
  • 27. PFAf Início Créditos Informação
  • 28. Development environment ● SL4A... – Emulador, adb. ● [allow_url_fopen, allow_url_include] -> ON – testnow.php – testcache.php ● Remote scripting.
  • 29. Script sharing ● SL4A scripts folder. ● Barcode (<4296 chars) ● Script on APK: – Template project -> customize. – ANT
  • 30. Roadmap ● SL4A – API extended. ● GUI... – Bugfixes. ● PFA – Sqlite,... phpize. – supporting SL4A releases.
  • 31. ????? Perguntas? Logo @Workoholics_