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
 
팀원과 정기면담, 도란도란 사례공유
팀원과 정기면담, 도란도란 사례공유팀원과 정기면담, 도란도란 사례공유
팀원과 정기면담, 도란도란 사례공유devCAT
 
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

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

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_