Julia

Зарегистрирован(а): 07/06/2007
PHP is everywhere, it has a huge Ecosystem of Libraries (like User’s Session Management, Security, …) which are still lacking in REBOL (though Rebol has all the network protocols and the very nice Parse to process strings, building a well-organised reusable framework takes time), so it makes sense to use PHP as Front-End to the External World by wrapping REBOL Objects - which would be considered to reside in the Business Layer in an Enterprise Application Architecture - and communicate between the two using a kind of RPC - instead of Web Services for better performance and integration when we can have control of both sides.
We have in fact already seen how to call a Rebol CGI from PHP, it’s now time to look at message passing from PHP to Rebol (the return message stays the same: the output of Linux/Windows standard I/O).
Let’s take the example of a search form. Instead of posting to Rebol CGI from the html form embedded in an HTML Page like this:
We would put the form in an index.php page and call the same index.php from the form
then within index.php we would test for the existence of the $_GET['s'] variable or not and forward to search.cgi passing the search term and any other other parameters we want by separating them with space, for example below, we also pass the command “search” at the end (this could be usefull if we have several kind of actions):
<?php
if (!isset($_GET['s'])) {
$command= './cgi-bin/index.cgi';
echo system($command);
}
else {
$searchterm = $_GET['s'];
$command= './cgi-bin/search.cgi '. '"' . $searchterm . '"' . ' ' . '"' . 'search' . '"';
echo system($command);
}
?>
On Rebol’s side we just have to pick the search term from the first element of system/options/args block (Rebol’s array):
#!/home/yourhostingaccount/yourdomain/rebol/rebol -c
REBOL [Title: "Search"]
command-line: system/options/args
search-term: pick command-line 1
]
If we want we could even make the script work in both context RPC or CGI by testing system/options/cgi/remote-addr:
#!/home/yourhostingaccount/yourdomain/rebol/rebol -c
REBOL [Title: "Search"]
test-remote: system/options/cgi/remote-addr;
;write/append/lines %log.txt mold test-remote
;write/append/lines %log.txt mold system/options/args
if/else (none? test-remote) [
command-line: system/options/args
search-term: pick command-line 1
][
print "content-type: text/html^/"
;==========================
do %cgi.lib.r
cgi: get-cgi
;write/append/lines %log.txt mold cgi
;==========================
search-term: cgi/s
;write %log.txt search-term
]
Of course this is just the basis of RPC between PHP and Rebol. A more standard serialization format could be defined furthermore using Rebol format or any other like JSON.
This is simple and flexible so that mixing PHP and Rebol should be a pleasure for both lovers of one language or the other while ripping the benefits from both sides : no more languages war :).
<!-- Social Bookmarks BEGIN -->
<!-- Social Bookmarks END -->
Он остановился как вкопанный,
Он остановился как вкопанный, сочно выругался и расхохотался во все горло Никакой ошибки быть не могло: три отчетливо видных следа спускались прямо к реке
solponticello prima-agro
solponticello prima-agro cool-for-you
icatconf girlwrestlermovie
icatconf girlwrestlermovie remontnoe
piramidu shirokoe zemnoe
piramidu shirokoe zemnoe
Опера мини для nokia Mini
Опера мини для nokia Mini Opera для Samsung Опера мини для самсунг
vor 2str bori
vor 2str bori
min autoska bestm
min autoska bestm
artic myde mira
artic myde mira
Отличный портал !
Отличный портал !
frankys.ru ruqmida.ru
frankys.ru ruqmida.ru scolim.ru
nvesta.ru goneweb.ru
nvesta.ru goneweb.ru slovani.ru
rentarate wunderkind-school
rentarate wunderkind-school dckras
krasdor spb.cnd.su
krasdor spb.cnd.su alternatefuel
lucky-angels ski-sportru
lucky-angels ski-sportru kalendarist
neptyn-servis music-line
neptyn-servis music-line
idelist.ru umlator.ru
idelist.ru umlator.ru ruchik.ru
опера для телефона бесплатно
опера для телефона бесплатно opera для телефона скачать opera на телефон
opera mini 6.1 для nokia
opera mini 6.1 для nokia
скачать Opera Mobile для
скачать Opera Mobile для Samsung
Отправить комментарий