Login   Register  
PHP Classes
elePHPant
Icontem

Developing PHP applications to run natively on Android phones - PHP Classes blog

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog Developing PHP applic...   Post a comment Post a comment   See comments See comments (12)   Trackbacks (5)  
<< Previous: 11th birthday and a ...>> Next: PHP for Android, PHP ...

Author: Manuel Lemos

Posted on:

Categories: Interviews, PHP community

The PHP For Android project was just launched. This article presents an interview with the project's lead developer. He explained how it works and what you can do to develop PHP applications that can run now on any Android device.




Iván Mosquera Paulo is a lead developer of the PHP For Android project. He gave the following interview.

PC = PHP Classes (Manuel Lemos)
PFA = PHP For Android (Iván Mosquera Paulo)

PC: First of all, congratulations for your initiative to bring PHP to the Android platform.

Can you please start to talk a bit about yourself, who you are, where you work, what you do and your background in the PHP and Android scene?

PFA: I am Iván Mosquera. I am a software engineer at Irontec. We are an Open Source company started 7 years ago. We are involved in a lot of Open Source projects with all kind of companies and government institutions. We develop our own VOIP solution based on Asterisk with an extra layer composed of several other projects.

Irontec team that worked on the project of PHP For Android phones

PHP is one of our regular tools. We have been a PHP company since our beginings. We are also working on our own PHP meta-framework called Karma. Apart from the PHP For Android project, I am also the lead developer of Evosugar (SugarCRM evolution integration plugin).

We are focusing on Open Source technologies, so Android is the obvious choice now. Last year we were involved in a few projects with Vodafone on which we developed a few Android apps in Java. However, our main tool is PHP. We knew about the existence of ASE (Android Scripting Environment). So we started working in supporting PHP For Android.

PC: Can you please describe a bit in more detail what is the goal of the PHP For Android project and why did you start it?

PFA: Yes, of course. Its first goal was providing support to ASE (Android Scripting Environment), recently renamed as SL4A (Scripting Layer for Android).

We were going to submit quite a big patch to achieve it, but it happened that the ASE folks were working in a refactoring. This refactoring was about making new interpreter support external to their project. That was when we thought about creating PHPForAndroid.net .

It is quite inspired on PHP.net. I mean, this project is not only about developing tools or apps. It is about helping PHP developers to get into the Android world for the first time without requiring to have a Java background.

So the first goal is achieved. It is already possible using PHP For Android with our unofficial ASE build and our PhpForAndroid-APK.

The next big thing is the script to APK issue. This is something killer in which the ASE (well, now S4LA) people are working and we are studying to support it and write documentation or tools ease it. Scripting for Android is no more geeky stuff thanks to the latest features.

We see a lot of potential in PHP For Android in custom apps like tracking your position and posting it depending in X conditions... The ASE API is quite big, the limit might be in the GUI but that is not really a problem in a lot of applications and we might work on improving that GUI API.

PC: It is interesting that you mentioned you work on Asterisk applications. There was a recent show in the TWIT network about FLOSS, on the Askozia PBX project which also uses PHP and jQuery to implement Asterisk appliances with user friendly Web interfaces.

But tell me, does the PHP For Android project allows PHP developers to build native Android applications, or is it something that still requires a Web server to run on the Android phone devices?

PFA: Our APK distributes a PHP-CLI binary, cross-compiled, linked to bionic (Android's libc) and just two extensions built-in, those required to talk to ASE: sockets and JSON . We may improve the binary with the help of the community of course.

So, no webserver required in Android. It is PHP-CLI and you have GUI access thanks to ASE's RPC server.

A frequently asked question is whether PHP-GTK is possible to run on Android. Well, AFAIK no because of the fact that Android lacks an X server.

PC: Interesting, but I just seen a video showing an implementation of KDE running on an Android device. Are you familiar with it?

PFA: I heard something about that but I am not sure if it is really being used.

We knew about ASE and we liked what the Python community already had. And we thought, why not? Lets go for PHP support.

Anyway, we are interested in other paths as well. It would be great having GTK for example.

PC: Right, X on Android devices is not a new thing, but I suppose that is not widely spread.

So, basically what does it take to have installed in Android phone to get PHP developers started?

PFA: We have put up a screencast showing the current process. Firstly, you need to install our own ASE build because current ASE (r25) does not support the features needed by PHP For Android.

Once installed, it is time to install PhpForAndroid.apk. It is an Android app which installs: the PHP binary, our Android PHP class (ported from the Python) and a few PHP script samples.

Once PHP For Android is installed, you should have those scripts available on Android and they should work. The easiest way to test the API and having fun is including your own remote code.

All these steps can be watched in the screencast.

PC: Do PHP developers need to have real Android phones or are there any simulators that can be used to try PHP on Android?

PFA: Good question. No, you do not need a real Android phone. You can play with the Android emulator. We might provide more info on this in our wiki.

What you see in the screencast is the emulator with a skin.

If you have an Android phone you need to know that Android OS 1.5 is required.

PC: Are there any fees that developers need to pay to get access to SDKs and other developer materials to start working on PHP on Android applications?

PFA: No. They are free software: gratis y libre. (gratis y libre is Spanish, in English it is the same word for both things: free)

PC: So, if somebody builds an Android application in PHP what he/she needs to do to make the application available on Android App Store? Is it possible already? Do you provide any tools to assist in that process?

PFA: That is the next big thing. That is a feature ASE developers are working on and according to them, it is already working.  We will see how it works and how easy it is for a PHP developer. We might provide tools and documentation to ease the process.

PC: I suppose that a PHP applications needs to also have installed your packages first in the Android device, right?

There are many Android devices in the market from different brands. Are the Android application installers device independent or do you need to have a specific PHP on Android runtime for each type of device?

PFA: All the current devices are ARM based and the PHP binary we provide is cross-compiled for ARM devices, so it should work out of the box on them. It is like an almost static PHP binary that you copy from a PC to another. It works and does not matter if it is AMD or Intel based.

We have heard about issues in ASE with a few devices but it is usually something related to a missing library, not really a common problem by now.

PC: Great. So in terms of developing PHP applications for Android, what is the current state of your project? Is it ready for starting developing interesting Android applications or only basic ones?

PFA: Now It is time to have fun. Try the ASE API, test our PHP binary, explore ASE's API limits. Once the script as APK feature is available we will be able to build Android apps with our code. Only basic ones? Well, it depends on ASE's API, which is a bit basic about GUI stuff but very interesting on the backend.

Besides, there is another path which is mixing both aproaches.

TwoFortyFourAM for example, I think it uses Python scripts as backend. So you do not need a whole Java team to achieve it. We have worked with that logic in a few desktop projects. Building the view with Swing and using PHP scripts in the backend powered by Quercus. Adding scripting to a Java app can be an interesting approach.

PC: OK, can you give a few examples of interesting applications you can already develop in PHP with this project?

PFA: For example GPS logging and mctl. Well, mctl is our way to talk about a protocol used by Irontec when Jabi Infante and Gorka Gorrotxategi (CTO) went to Mongolia by car.

You take your position via GPS and then you can send data using missed calls against a few DID numbers which represent binary encoded data. For example, you want to transfer the number 1 (0000001) so you can make a missed call to the first DID. It was a little bit complex because they had to start and stop the transfer, checksum and so on. It was a whole protocol :).

So, as I have said, you can already have fun with PHP For Android with ideas like this one.

PC: Great, sounds like you implemented some advanced hacks.

Another question, most PHP applications are MySQL based. Is MySQL already available, or at least SQLite, for use in PHP Android applications?

PFA: I don't think so. I don't know whether there is some kind of database storage exposed by the ASE API. Anyway, Android phones are usually Internet based, so you can think of PHP For Android in a role like JavaScript in Web applications, you can call server code.

And this is related to the built-in extensions on PHP. We want to keep the binary as light as possible but the discussion is open.

PC: Right, I guess at least SQLite can be shipped built-in because it is very simple and does not require any external servers or libraries.

Now a bit on the market and business opportunities. The Android phone market seems to have exploded lately in reach. We hear about 5 million Android smart phones of many different brands being sold around the world just in the last month.

Do you think your project can represent a good opportunity for the developers to make even more money selling Android applications or providing other services, than they would doing regular PHP Web applications? What is your guess?

PFA: I hope so. Apple does not want PHP developers, they want you to invest in their technology. With Android, you have freedom of choice: Java, AIR, scripting (Python, now PHP,...).

Besides, a lot of Web developers might try Android development thanks to PFA. They can reuse their current know-how.

PC: Good. Another commercial concern, I suppose your project requires PHP applications to be installed with PHP code. Commercial developers would have concerns about customers ripping their PHP code.

Do you recommend any solution for protecting the PHP applications source code from being stollen or altered? Do you think for instance Facebook's Hip-Hop PHP to C++ compiler could be used to solve that problem?

PFA: Well, we are an Open Source company. So we are not really worried about that. However I understand that there might be people interested in using a different commercial policy. Hip-Hop, can be interesting. Obfuscation is sometimes used in Web development. Anyway, we recommend a more open policy.

PC: OK. So, what are your immediate plans for the future of this project?

PFA: We want people involved in sharing scripts, testing, discussion, learning ASE's API, have fun. The script as APK feature provided by SL4A will be the next big thing.

PC: Are you looking for help in your project? If so, what other developers can do to join you and help evolving the project faster?

PFA: Any PHP developer can help sharing scripts. We will give them credit, of course. Besides, testing is needed, and documentation, we want to have some kind of PFA official manual.

Speaking about the internals, a bit Java and PHP compiling knowledge may be necessary, maybe a bit of C too. However, I think that this is not so important now. We can already work with the current release.

PC: Great. Is there anything else you would like to say besides what was asked, maybe how other developers or companies can get in touch with your company?

PFA: You can get in touch with our company via email (info at irontec.com). Besides that, we usually talk about the things we do in our blog. Irontec's Twitter account is also very active.

For contacting about PHPForAndroid project, the best way is to join the project mailing list.

PC: Thank you very much for this interview. Good luck for your project.

PFA: Thanks, great interview.

You need to be a registered user or login to post a comment

Login Immediately with your account on:

Facebook ConnectGmail or other Google Account
Hotmail or Microsoft Windows LiveStackOverflow
GitHubYahoo


Comments:

3. How does it work? - danny (2012-02-13 09:36)
How does it work?... - 6 replies
Read the whole comment and replies

2. Lindo - André Guariento (2010-07-29 02:05)
Desse jeito vamos competir com o Java... - 0 replies
Read the whole comment and replies

1. PHP for Android - Kent Allen (2010-07-26 07:48)
Awesome!... - 3 replies
Read the whole comment and replies


Trackbacks:

5. PHP FOR ANDROID – CHALLENGE ACCEPTED (2011-03-03 06:21)
Hoy a llegado a mí la noticia de una librería para desarrollar aplicaciones para android mediante scripts de PHP.

4. PHP For Android (2010-09-30 12:52)
Irontec mühendislerinin gelistirdigi APK...

3. PHP agora funciona no Android: PhpForAndroid (2010-07-15 19:30)
Uma descoberta interessante que chama a atenção de desenvolvedores PHP como eu...

2. PHP für die Entwicklung von Android-Apps (2010-07-15 01:56)
PHP auf Smartphones mit Android? Das will jetzt das spanische Software-Unternehmen Irontec schaffen und hat dafür seine erste Version von PHP for Android veröffentlicht...

1. My first PHP for Android experience (2010-07-15 01:02)
A couple of days ago I made a quick Internet research to find whether I can write PHP applications for my HTC Desire which runs under Android 2.1...


<< Previous: 11th birthday and a ...>> Next: PHP for Android, PHP ...

  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog Developing PHP applic...   Post a comment Post a comment   See comments See comments (12)   Trackbacks (5)