473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

PHP as an embedded scripting language

......ie in my application!

Basically I want to add a scripting language to a cross platform
application. The prime requirements are that it is:

a) Small
b) May be easily staticlly compiled into the app and require nothing
more than libc and sockets.
c) It must be easy to add new functions in C to hook into the app.
d) Reasonably easy to learn and use.

After looking at the many options available I have almost settled on
Lua, however I would **like** to use PHP, I have used the apache PHP
module for server side scripting in the past and like it. It has been
excluded a bit from my choice because I could not find out anything
**about** using it as an embedded scripting language for apps, and any
attempt to search for e.g "PHP embedded" results in zillions of
references to embedding in HTML etc.

Can anybody give me any pointers or tips on this aspect/use of the
language?

Oct 19 '05 #1
6 1823
Roger wrote:
.....ie in my application!

Basically I want to add a scripting language to a cross platform
application. The prime requirements are that it is:

a) Small
b) May be easily staticlly compiled into the app and require nothing
more than libc and sockets.
c) It must be easy to add new functions in C to hook into the app.
d) Reasonably easy to learn and use.

After looking at the many options available I have almost settled on
Lua, however I would **like** to use PHP, I have used the apache PHP
module for server side scripting in the past and like it. It has been
excluded a bit from my choice because I could not find out anything
**about** using it as an embedded scripting language for apps, and any
attempt to search for e.g "PHP embedded" results in zillions of
references to embedding in HTML etc.

Can anybody give me any pointers or tips on this aspect/use of the
language?


PHP ia not compiled, so it won't meet your second requirement.
Additionally, I've never seen it embedded in anything but html. While I
see no reason why it couldn't be, it's the Apache (or IIS) PHP module
which senses the <?php and ?> tags and passes what's between them to the
interpreter. You'd have to create a similar module for a standalone app.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 19 '05 #2

Jerry Stuckle wrote:

PHP ia not compiled, so it won't meet your second requirement.
Oops, no, I misled you there! What I meant was that I need to compile
the interpreter into the application. The embedded interpreter would
interpret uncompiled code.
Additionally, I've never seen it embedded in anything but html. While I
see no reason why it couldn't be, it's the Apache (or IIS) PHP module
which senses the <?php and ?> tags and passes what's between them to the
interpreter. You'd have to create a similar module for a standalone app.


PHP can run as a stanalone interpter. In fact the CGI version is quite
capable as being used as such (or rather **it is** a standalone
interpreter).

However, as you point out, it is pratically always used in web server
scenarious, I don't no how much this has detracted from it's
suitability as an embedded scripting engine.

Oct 19 '05 #3
NC
Roger wrote:

PHP can run as a stanalone interpter. In fact the CGI version is quite
capable as being used as such (or rather **it is** a standalone
interpreter).

However, as you point out, it is pratically always used in web server
scenarious, I don't no how much this has detracted from it's
suitability as an embedded scripting engine.


Well, there's also the command-line interpreter...

Cheers,
NC

Oct 19 '05 #4
Roger wrote:
Jerry Stuckle wrote:

PHP ia not compiled, so it won't meet your second requirement.

Oops, no, I misled you there! What I meant was that I need to compile
the interpreter into the application. The embedded interpreter would
interpret uncompiled code.

Additionally, I've never seen it embedded in anything but html. While I
see no reason why it couldn't be, it's the Apache (or IIS) PHP module
which senses the <?php and ?> tags and passes what's between them to the
interpreter. You'd have to create a similar module for a standalone app.

PHP can run as a stanalone interpter. In fact the CGI version is quite
capable as being used as such (or rather **it is** a standalone
interpreter).

However, as you point out, it is pratically always used in web server
scenarious, I don't no how much this has detracted from it's
suitability as an embedded scripting engine.


Roger,

I don't know how you could compile the interpreter into your program. I
suspect it would be quite difficult, requiring some changes to the
interpreter code. But I guess it could be done.

Alternatively, you could call the command line interpreter and buffer
the contents back into your program by redirecting stdout to a pipe.

I think it would be difficult, though. Remember - PHP itself doesn't
have any real user interface other than a command line prompt.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 19 '05 #5

Jerry Stuckle wrote:
I think it would be difficult, though. Remember - PHP itself doesn't
have any real user interface other than a command line prompt.


Allthougth it is not very relevant to my problem, I would point out
that there is a PHPGTK project http://gtk.php.net/ which binds GTK
widgets to a PHP engine, and thus **does** allow you to create stand
alone GUI apps with PHP.

The apps will run on any platform GTK runs on (Win, *nix, Mac ......)

Oct 20 '05 #6
Roger wrote:
Jerry Stuckle wrote:

I think it would be difficult, though. Remember - PHP itself doesn't
have any real user interface other than a command line prompt.

Allthougth it is not very relevant to my problem, I would point out
that there is a PHPGTK project http://gtk.php.net/ which binds GTK
widgets to a PHP engine, and thus **does** allow you to create stand
alone GUI apps with PHP.

The apps will run on any platform GTK runs on (Win, *nix, Mac ......)

I would recommend downloading the php source code and running around in
there. It should be too hard to compile it into your own program. You
would just need to load up the zend engine everytime you were about to
parse some type of php document.

--
Mike Willbanks
Zend Certified Engineer
http://www.digitalstruct.com
Oct 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Brandon | last post by:
Java seems to have taken off as the platform and language of choice for many embedded devices. Would it be feasible for Python(perhaps running on an embedded version of Linux) to act in such a...
5
by: John Benson | last post by:
Regarding the message appended below: I was in a similar situation, only I had 4 "small" (RAM-wise) legacy processors in a fault-tolerant Tandem K100 system. The system came with an old Borland C++...
2
by: Markus Dehmann | last post by:
I'd like to process text or document templates that use "embedded C++". Here is a constructed example (the texts I have in mind are much longer and contain relatively few code blocks): ...
20
by: Jack | last post by:
Is there a Python packaging that is specifically for embedded systems? ie, very small and configurable so the user gets to select what modules to install? For Linux-based embedded systems in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.