So I have been issued a project with tight restrictions, I need to run php files stored in local app directory for a WebView application. However I dont even know where to start as for implementing or integrating
I see the following apps in google play, claiming to have php server, mysql, etc.
https://play.google.com/store/apps/details?id=com.sylkat.apache
So I know there is possibility to run php files within android application.
What my idea is,
What I am NOT seeking for in this question
I am aware php is server sided code.
This is a list of challenges you face if you wish to run PHP code on a modern Android device.
I searched and found some projects implying that PHP can be run on Android
While I can't speak to any closed source projects, there are a few open source one, DroidPHP and more recent ones MyServer and lampTermux . But a bit of history/background is needed to understand what these projects represent.
PHP is written in C/C++. While Android does support C/C++ via the Android NDK, what's missing is that a PHP server expects to be run in a constant power Posix compliant environment which Android does not support out of the box .
The first one DroidPHP
, which appears abandoned by the author, uses Busybox which provides a POSIX compatible environment but requires superuser/root permission which requires 'rooting' the Android device . Note that 'rooting' generally voids device warranties.
With billions of users over the years, the Android ecosystem has increased thesecurity of each version reducing the attack surface for any bad-actor.
The other two github projects use Termux which provide a POSIX-like environment, which can be used with root and in a more limited fashion without root.
Hey that sounds great, so I can use
Termux
to run my PHP code.
A few caveats:
Android manufacturers have added in their own battery saving processing resulting in a site like: https://dontkillmyapp.com/ if your app only runs in foreground you are probably safe.
From the Termux repo README regarding Android 12:
NOTICE: Termux is broken on Android 12. Android OS will kill any (phantom) processes greater than 32 (limit is for all apps combined) and also kill any processes using excessive CPU.
Yes, as Termux is open-source and uses a GNU GPL v3.0 and in some components Apache-2.0 license, you can freely re-use existing components as soon as you met the license requirements.
However license does not cover "free" use of our hosting capabilities which are somewhat limited. You cannot use our package repositories in your own project(s). Please build packages and host them yourself.
Get started with information on developer's wiki pages: https://github.com/termux/termux-packages/wiki .
Termux
(and its requirements for operation) is currently incompatible.If you follow the embedded attempt issue thread you'll see that embedding is a involved process.
Sources: https://www.reddit.com/r/termux/comments/p3exkr/how_can_i_make_an_android_apk_app_based_on_termux/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.