BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delphi/PHP as a (local) web server ??
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Peter Richards
Guest





PostPosted: Sat Jan 24, 2004 2:13 am    Post subject: Delphi/PHP as a (local) web server ?? Reply with quote



Hi,

I need a 'local' web server, that will be able to parse/interpret PHP
web pages, and make them viewable/updatable from Delphi.

I notice there is a product called 'PHP4Delphi" by Serge Perevoznyk,
at http://users.chello.be/ws36637/php4delphi.html

"PHP4Delphi is a Delphi interface to PHP for Delphi 5, 6 and 7.
PHP4Delphi allows to execute the PHP scripts within the Delphi program
directly without a WebServer.
PHP4Delphi also contains PHP API and ZEND API and PHP extension visual
development framework."

So it seems this product will 'act' like a 'web server' (Apache for
instance), but only needs Delphi and the PHP4Delphi components,
libraries,etc, which include the Zend scripting engine (which is
needed to run PHP).

This is probably about 90% of what I need for a special project. At
present, a client uses another product, which is (sort of) like a
"website builder". You specify your products, categories, company
parameters, specify images, etc,etc in an (Access) db, then select a
template, press a few buttons, and your 'website' is built locally, on
your Win box. Then after reviewing/changing, you can upload the
changed 'parts' to your website.

The client likes it because he can change stuff locally (like product
decsriptions, he can insert html tags,etc), review it, change it some
more, and _then_ when he is happy, upload it. Also, if a person rings
up about a product, he just has to go to his computer, and not the
internet to check. That said, there are many things he doesn't like,
like the high hosting fees, and the product cannot be run on a *nix
box, and to run it on a Win server, you need to also run their
'speciallly built' web server. The same web server runs locally and
remotely, so there are not many web hosting companies that would agree
to run such a 'server'. In summary, the product is way too much of a
proprietary nature, and has users locked into a corner.

Considering what I have said about the current product (i.e. what the
person does like), and the fact that PHP4Delphi appears like a
definite step in the right direction, what would be required to
create/build a similar tool/product for this person to use locally ??

There would be PHP scripts to 'interpret', and there also may be a
MySQL db. I would want the Delphi application to be able to:

* Act like a web server, parsing the PHP and returning the html output
* Also be able to 'run' the PHP , which updates the db
* Have addition functions to change things on the website and upload
(SFTP) the changed 'parts'

It is not necessary to have this bundled into one product, possibly
easier to have:

* The 'server' as the stock/std 'PHP4Delphi'
* Build a small Delphi app to do any other features and handle the
FTP side,etc

Your advise would be appreciated, please. :)

Peter


Peter Richards
[email]peter_j_richards (AT) nospamplease (DOT) com[/email]
(but use hotmail to email)
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Jan 24, 2004 3:44 am    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote




"Peter Richards" <peter_j_richards (AT) nospamplease (DOT) com> wrote


Quote:
I need a 'local' web server, that will be able to parse/interpret
PHP web pages, and make them viewable/updatable from Delphi.

PHP itself is just an executable. Whatever server you decide to make, all
you have to do when you receive an HTTP request for executing a PHP script
is to spawn an instance of php.exe, passing it the appropriate script
filename as a command-line parameter.

Also, you would have to provide your own STDIN and STDOUT handles for the
spawned process so that you can pipe the client's request data to php.exe
and pipe its response data back to the client. You can use CreateProcess(),
CreatePipe(), ReadFile(), and WriteFile() for that task.

Quote:
So it seems this product will 'act' like a 'web server'

That is not what that page was saying at all. PHP itself is just an
executable application. What that page is saying is that your Delphi
application can executable PHP directly with the appropriate parameters and
such. That has nothing to do with whether it will act as a web server or
not, because it doesn't do that. If you need to provide web access to your
program, you still have to provide one yourself.

Quote:
Considering what I have said about the current product (i.e. what
the person does like), and the fact that PHP4Delphi appears like
a definite step in the right direction, what would be required to
create/build a similar tool/product for this person to use locally ??

If his local program requires a local web server to view local web content,
then you still need to provide an actual web server for his program to
connect to and send requests to. Whether you use PHP4Delphi to execute PHP
scripts or not in a server you create yourself, that does not really matter
as that is simply an internal implementation detail on the server's part.

Quote:
* The 'server' as the stock/std 'PHP4Delphi'

Rather than write your own server for that, there are already plenty of
third-party servers, both freeware and shareware, that do that. I myself
use Omni HTTPd, http://www.omnicron.ca. It is a freeware light-weight
server that supports both Perl and PHP.


Gambit



Back to top
Ben Hochstrasser [FF]
Guest





PostPosted: Sat Jan 24, 2004 11:30 am    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote



Remy Lebeau (TeamB) wrote:

Quote:
Rather than write your own server for that, there are already plenty of
third-party servers, both freeware and shareware, that do that. I myself
use Omni HTTPd, http://www.omnicron.ca. It is a freeware light-weight
server that supports both Perl and PHP.

The page says that the free version runs on win95 only.
Better get BRS WebWeaver ([url]http://www.brswebweaver.com/)[/url]. It's a lightweight
HTTP and FTP server which supports cgi, php, perl and isapi.

--
Ben

Back to top
Dennis Landi
Guest





PostPosted: Sat Jan 24, 2004 3:38 pm    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote


--
Find a BUG?
Think its Borland's?
Ask your peers in the news groups?
Still think its Borlands?
http://qc.borland.com
"Peter Richards" <peter_j_richards (AT) nospamplease (DOT) com> wrote

Quote:
Hi,

I need a 'local' web server, that will be able to parse/interpret PHP
web pages, and make them viewable/updatable from Delphi.

I notice there is a product called 'PHP4Delphi" by Serge Perevoznyk,
at http://users.chello.be/ws36637/php4delphi.html

"PHP4Delphi is a Delphi interface to PHP for Delphi 5, 6 and 7.
PHP4Delphi allows to execute the PHP scripts within the Delphi program
directly without a WebServer.
PHP4Delphi also contains PHP API and ZEND API and PHP extension visual
development framework."

So it seems this product will 'act' like a 'web server' (Apache for
instance),

No you still need an http server. You can either find one that you can
compile in Delphi, or you can go the delphi/ISAPI route. Either way, you
should be able to embed the PHP4Delphi component directly into your code.
That's the point.



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Jan 24, 2004 11:04 pm    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote


"Ben Hochstrasser [FF]" <bhoc@tiscali123^H^H^H.ch> wrote


Quote:
The page says that the free version runs on win95 only.

You are looking at the old old version. I use the Pro version myself. It
is fully functional other than it expires once a year, but Omni has always
posted a new release prior to the expiration, so it is just a matter of a
single download once a year to reset the expiration, and it is free
otherwise. Of course, you can pay extra to remove the expiration.


Gambit



Back to top
Peter Richards
Guest





PostPosted: Mon Jan 26, 2004 3:47 am    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Hi,

On Fri, 23 Jan 2004 19:44:14 -0800, "Remy Lebeau (TeamB)"
<gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote:

Quote:

"Peter Richards" <peter_j_richards (AT) nospamplease (DOT) com> wrote in message
news:1sj310lmb85ufhiomio7d53gepr748j803 (AT) 4ax (DOT) com...

I need a 'local' web server, that will be able to parse/interpret
PHP web pages, and make them viewable/updatable from Delphi.

PHP itself is just an executable. Whatever server you decide to make, all
you have to do when you receive an HTTP request for executing a PHP script
is to spawn an instance of php.exe, passing it the appropriate script
filename as a command-line parameter.

Yes, I understand that a PHP script cannot be 'inperpreted' by a HTTP
request without php.exe, however, as the author has converted the
scipting engine (Zend) to a .PAS, then it would also seem possible to
include this (.pas) scripting engine in a Delphi executable, as long
as you have php4ts.dll included ?

Quote:
Also, you would have to provide your own STDIN and STDOUT handles for the
spawned process so that you can pipe the client's request data to php.exe
and pipe its response data back to the client. You can use CreateProcess(),
CreatePipe(), ReadFile(), and WriteFile() for that task.

Okay, thanks, there may also already be some method of handing this
withiin the PHP4Delphi package.

Quote:
So it seems this product will 'act' like a 'web server'

That is not what that page was saying at all. PHP itself is just an
executable application. What that page is saying is that your Delphi
application can executable PHP directly with the appropriate parameters and
such. That has nothing to do with whether it will act as a web server or
not, because it doesn't do that. If you need to provide web access to your
program, you still have to provide one yourself.

I may not need a web server, as such, after looking at PHP4Delphi.
What I do need to do, is to develop a Delphi application, that can
display PHP pages, that is, interpret them (Zend engine), and pass it
back to a browser (maybe some Indy components ?), so that a user can
see and use (add/update to a MySQl db , using the PHP application) the
dynamic html pages. This will only be needed locally, on a PC.

Quote:
Considering what I have said about the current product (i.e. what
the person does like), and the fact that PHP4Delphi appears like
a definite step in the right direction, what would be required to
create/build a similar tool/product for this person to use locally ??

If his local program requires a local web server to view local web content,
then you still need to provide an actual web server for his program to
connect to and send requests to.

The only reason his local program needs a local web server, is because
there are embedded 'tags' within the .html pages, that are, like many
scripting languages (VBS,PHP,etc) interpreted by the local web server,
for one purpose only, to be able to view the 'website'. These embedded
tags are only used by the product, so all the users are 'locked into'
the product.

Quote:
Whether you use PHP4Delphi to execute PHP
scripts or not in a server you create yourself, that does not really matter
as that is simply an internal implementation detail on the server's part.

Yes, I may not need a 'server' as such, I remember when I first got
Delphi 6, and there were some examples of viewing html in a
'delphi/browser', using Indy components possibly. That was though,
static html, not dynamic, like that produced by PHP or ASP,etc.

Quote:
* The 'server' as the stock/std 'PHP4Delphi'

Rather than write your own server for that, there are already plenty of
third-party servers, both freeware and shareware, that do that. I myself
use Omni HTTPd, http://www.omnicron.ca. It is a freeware light-weight
server that supports both Perl and PHP.

Ok, thanks for your help,

Peter


Peter Richards
[email]peter_j_richards (AT) nospamplease (DOT) com[/email]
(but use hotmail to email)

Back to top
Peter Richards
Guest





PostPosted: Mon Jan 26, 2004 3:48 am    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Hi,

On Sat, 24 Jan 2004 12:30:07 +0100, "Ben Hochstrasser [FF]"
<bhoc@tiscali123^H^H^H.ch> wrote:

Quote:
The page says that the free version runs on win95 only.

Well, I only have Win95, so maybe I'm in luck. :)

Quote:
Better get BRS WebWeaver ([url]http://www.brswebweaver.com/)[/url]. It's a lightweight
HTTP and FTP server which supports cgi, php, perl and isapi.

Thanks, I'll check that out.

Peter


Peter Richards
[email]peter_j_richards (AT) nospamplease (DOT) com[/email]
(but use hotmail to email)

Back to top
Peter Richards
Guest





PostPosted: Mon Jan 26, 2004 3:53 am    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Hi Dennis,

On Sat, 24 Jan 2004 10:38:32 -0500, "Dennis Landi" <none[at]none.com>
wrote:

Quote:
So it seems this product will 'act' like a 'web server' (Apache for
instance),

No you still need an http server. You can either find one that you can
compile in Delphi, or you can go the delphi/ISAPI route. Either way, you
should be able to embed the PHP4Delphi component directly into your code.
That's the point.

Not too sure if I _really_ need a (local) web server, simply to
view/review the PHP pages, assuming I can include the Zend scripting
engine from PHP4Delphi, within the Delphi application.

Peter


Peter Richards
[email]peter_j_richards (AT) nospamplease (DOT) com[/email]
(but use hotmail to email)

Back to top
Ben Hochstrasser [FF]
Guest





PostPosted: Mon Jan 26, 2004 7:47 am    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Peter Richards wrote:

Quote:
Not too sure if I _really_ need a (local) web server, simply to
view/review the PHP pages, assuming I can include the Zend scripting
engine from PHP4Delphi, within the Delphi application.

Unless the scripts need the environment variables usually supplied by the
web server. Personally I don't see a fundamental gain in using PHP4Delphi
plus a .dll versus using PHP.exe.

PHP does no miracles, it's "simply" a Hypertext preprocessor (a very good
one, I might add). But it doesn't do any rendering etc for you - you'd
still need a browser component.

Personally I'd go and install the very same PHP that the web server too
would need, run it in .cgi mode and catch its output from within delphi.

With specially crafted APIs and .dlls you always are in danger of forking
code (where your special version is always one or two releases behind)

--
Ben

Back to top
Serhiy Perevoznyk
Guest





PostPosted: Mon Jan 26, 2004 8:26 pm    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Quote:
PHP itself is just an executable.
You are completely wrong. PHP itself is an engine (php4ts.dll in case of

Windows) and set of special SAPI (server API) modules for different HTTP
servers. PHP executable is just one particular case for CGI scripting. For
example, IIS uses php4isapi.dll as an interface to PHP engine, Apache uses
php4apache.dll, etc

Quote:
Also, you would have to provide your own STDIN and STDOUT handles for the
spawned process

If you want to use PHP within your application you can use Indy idHTTPServer
and
idISAPIRunner + php4Isapi, idCGIRunner + php.exe or just idPHPRunner
component.
You will have exactly the same results as using IIS or Apache
All these components available from the same page
http://users.chello.be/ws36637/

Quote:
That is not what that page was saying at all. PHP itself is just an
executable application. What that page is saying is that your Delphi
application can executable PHP directly with the appropriate parameters
and
such.

The page is saying that you can use PHP as a scripting language in your
application. For example, you can execute script like :
Button1.Caption = 'I am button';

It means that psvPHP component uses PHP engine directly using PHP API and
not PHP.EXE
It means also than psvPHP is not a component for server -side development.
It is a scripting for applications (like VBA for Office). It is a PHP
extension that enables you to write client-side _GUI_ applications.
One of the goals behind it was to prove that PHP is a capable
general-purpose scripting language that is suited for more than just Web
applications. It is intended for creating standalone GUI applications.

Quote:
That has nothing to do with whether it will act as a web server or
not, because it doesn't do that.
Indeed, php4Delphi is not a web-server at all. I already explained what is

real purpose of the psvPHP component.
php4Delphi aslo contains a visual framework for development of PHP
extensions (special modules for PHP) using Delphi.
But in this case Delphi is used for PHP development, but not PHP for Delphi
development.
More information about php4Delphi you can find in "International PHP
magazine"
http://www.php-mag.net/itr/ausgaben/psecom,id,177,nodeid,112.html
and about using psvPHP component in very nice PowerPoint presentation made
by Colin Nelson
http://www.waycyber.com/att1p.zip

Serhiy Perevoznyk
http://users.chello.be/ws36637/



Back to top
Serhiy Perevoznyk
Guest





PostPosted: Mon Jan 26, 2004 8:40 pm    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Quote:
Yes, I understand that a PHP script cannot be 'inperpreted' by a HTTP
request without php.exe,
Yes, php script can be interpreted by HTTP server perfectly _without_

php.exe

Quote:
scipting engine (Zend) to a .PAS, then it would also seem possible to
include this (.pas) scripting engine in a Delphi executable, as long
as you have php4ts.dll included ?
You are right. Try idPHPRunner component, for example


Quote:
Okay, thanks, there may also already be some method of handing this
withiin the PHP4Delphi package.
executution of php script using psvPHP looks like:


var
st : string;
....
st := psvPHP.RunCode('phpinfo();');

Quote:
I may not need a web server, as such, after looking at PHP4Delphi.
http://www.toflidium.com/weblog/articles/phparch.html

http://www.phparch.com/issue.php?mid=16


Serhiy Perevoznyk
http://users.chello.be/ws36637/



Back to top
Serhiy Perevoznyk
Guest





PostPosted: Mon Jan 26, 2004 8:53 pm    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Quote:
Unless the scripts need the environment variables usually supplied by the
web server. Personally I don't see a fundamental gain in using PHP4Delphi
plus a .dll versus using PHP.exe.
I don't see it either. But using php4isapi.dll and Indy HTTP server for

certain gives big advantage versus php.exe

Quote:
PHP does no miracles, it's "simply" a Hypertext preprocessor (a very good
one, I might add). But it doesn't do any rendering etc for you
And what is php-gtk in this case?


Quote:
With specially crafted APIs and .dlls you always are in danger of forking
code (where your special version is always one or two releases behind)
SAPI (server API) is quite stable and provides all nessesary functionality.

For you information, php.exe is also written using exacltly the same PHP API
as php4isapi, for example.

Serhiy Perevoznyk



Back to top
Ben Hochstrasser [FF]
Guest





PostPosted: Mon Jan 26, 2004 9:02 pm    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Serhiy Perevoznyk wrote:

Quote:
SAPI (server API) is quite stable and provides all nessesary
functionality. For you information, php.exe is also written using
exacltly the same PHP API as php4isapi, for example.

I didn't mean to say there's imminent forking danger in php4delphi etc.
I remember that eg for SQLite someone rewrote the C++ api to use STDCALL
rather than CDECL. Of course, that version always lagged behind... As long
as one and the same developer team takes care of various flavours of
interfaces - no problem.

--
Ben

Back to top
Peter Richards
Guest





PostPosted: Tue Jan 27, 2004 1:24 am    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Hi Serhiy,

On Mon, 26 Jan 2004 21:40:16 +0100, "Serhiy Perevoznyk"
<serge_perevoznyk (AT) hotmail (DOT) com> wrote:

Quote:
Yes, I understand that a PHP script cannot be 'inperpreted' by a HTTP
request without php.exe,
Yes, php script can be interpreted by HTTP server perfectly _without_
php.exe

Thanks for clarifying that for me. That is good news, because when
deploying the Delphi application for use on a local computer, the less
I have to 'bundle together' the better, also there may be OS issues
with php.exe (which I have already found out with Win95, the highest
version I can use is 4.2.3 (.

Quote:
scipting engine (Zend) to a .PAS, then it would also seem possible to
include this (.pas) scripting engine in a Delphi executable, as long
as you have php4ts.dll included ?
You are right. Try idPHPRunner component, for example

Okay, I noticed that on your website.

Quote:
Okay, thanks, there may also already be some method of handing this
withiin the PHP4Delphi package.
executution of php script using psvPHP looks like:

var
st : string;
...
st := psvPHP.RunCode('phpinfo();');

Will give that a try. I do now already have PWS installed, and it can
return (most) PHP scripts in a browser, but those few lines compiled
in a Delphi app will sure make it easier.

Quote:
I may not need a web server, as such, after looking at PHP4Delphi.
http://www.toflidium.com/weblog/articles/phparch.html
http://www.phparch.com/issue.php?mid=16

I would like to read that article, sounds interesting.

Thanks,

Peter


Peter Richards
[email]peter_j_richards (AT) nospamplease (DOT) com[/email]
(but use hotmail to email)

Back to top
Peter Richards
Guest





PostPosted: Tue Jan 27, 2004 1:34 am    Post subject: Re: Delphi/PHP as a (local) web server ?? Reply with quote

Hi,

On Mon, 26 Jan 2004 21:26:37 +0100, "Serhiy Perevoznyk"
<serge_perevoznyk (AT) hotmail (DOT) com> wrote:

Quote:
More information about php4Delphi you can find in "International PHP
magazine"
http://www.php-mag.net/itr/ausgaben/psecom,id,177,nodeid,112.html

I notice that the Jan 2004 edition has an article on PHP4Delphi

"PHP4Delphi Framework
Writing Extension Modules with Borland Delphi
By Milan Petrovic
An in-depth review of the PHP4Delphi framework that can be used to
write your own PHP extensions in Delphi instead of C(++)."

Peter


Peter Richards
[email]peter_j_richards (AT) nospamplease (DOT) com[/email]
(but use hotmail to email)

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.