View previous topic :: View next topic |
Author |
Message |
anonybosh Guru
Joined: 20 Nov 2005 Posts: 324
|
Posted: Sun Jun 03, 2007 7:33 pm Post subject: PHP-parsing web browser plugin? |
|
|
Is there a plugin for web browsers (Konqueror, Firefox, etc.) that will parse a local PHP document and display the output, allowing refreshes to re-parse the php document?
I have created a script for my Konq browser that sort of does what I want, but I would really like a method of being able to press 'reload' in the browser, and have it re-parse the page, as well as instead of opening a new tab/window, follow just like any other link: into the same window/tab.
Code: | #!/bin/bash
for file in $*
do
FILENAME=`ls $file|gawk -F "[./]" '{print $(NF-1)}'`
php $file > $file"_test.html"
INSTANCES=`dcop | grep konqueror`
# Call konqeuror
if [ -n "$INSTANCES" ]; then # If a konqueror instance exists
# Parse the first instance
for FIRST_INSTANCE in $INSTANCES;
do
break;
done
# Use DCOP to tell the instance to spawn a new window of our URL
dcop $FIRST_INSTANCE konqueror-mainwindow#1 newTab "$file"_test.html""
fi
done |
I just have this script associated with .php files in Konq.
Is there such a plugin in existence? Is there such a plugin for any interpretive language (such as python, ruby, etc.)? |
|
Back to top |
|
|
AllenJB Veteran
Joined: 02 Sep 2005 Posts: 1285
|
Posted: Mon Jun 04, 2007 7:38 am Post subject: |
|
|
I've never heard of such a plugin. PHP is a server-side language designed to run on webservers. IMO you're best off setting up a local copy of Apache and running PHP off there. Apache is fairly easy to set up, with lots of tutorials available on the web and good documentation on the Apache website. There are also neat "tricks" you can do, such as having multiple domains by adding extra lines to you /etc/hosts file (again, further documentation available on the web).
With Gentoo, to get a basic copy of Apache + PHP running, all you need to do is add the following line to /etc/portage/package.use (create the file if it doesn't exist - see the Gentoo Handbook for more information on controlling USE flags for individual packages):
dev-lang/php apache
Then run: emerge dev-lang/php
This will install Apache + PHP and I'm fairly sure they work "out of the box" - all you'll want to do is either add some virtual hosts to apache's config or change where it looks for files (DocumentRoot). I won't go into this here because as I said above there's plenty of tutorials and documentation on this already. |
|
Back to top |
|
|
phajdan.jr Retired Dev
Joined: 23 Mar 2006 Posts: 1777 Location: Poland
|
Posted: Mon Jun 04, 2007 10:47 am Post subject: |
|
|
Yeah, do what AllenJB said. I can add that it probably is possible to do what you want, but it would be hackish, inelegant, error prone and whatever else. (L)A(M)P setup may seem to be more difficult, but once you do it, you'll see that actually it's quite easy (especially on Gentoo), and it's stable and JustWorks(tm). |
|
Back to top |
|
|
dleverton Guru
Joined: 28 Aug 2006 Posts: 517
|
Posted: Mon Jun 04, 2007 11:30 am Post subject: |
|
|
For the record, such a thing did exist: http://www.thomas-schilz.de/MozPHP/. But it's old and probably doesn't work with recent Mozilla versions. |
|
Back to top |
|
|
anonybosh Guru
Joined: 20 Nov 2005 Posts: 324
|
Posted: Mon Jun 04, 2007 5:35 pm Post subject: |
|
|
Quote: | IMO you're best off setting up a local copy of Apache and running PHP off there. Apache is fairly easy to set up, with lots of tutorials available on the web and good documentation on the Apache website. There are also neat "tricks" you can do, such as having multiple domains by adding extra lines to you /etc/hosts file (again, further documentation available on the web). | Setting up a a web server to do the job certainly is the easiest way to go, however, since my server has one running, I don't really want to have another run locally on my laptop just for development. I just want a simple, low-overhead way to view/test my coding prior to submitting it via SVN to my server.
Thanks for the link! It does look kind of old...only uses php4...
It looks like I am going to need to stick with my script for now, I guess, until I (or someone else) writes (ideally KDE based, a KPart) plugin to handle such a use.
BTW, I updated my script a little: Code: | #!/bin/bash
# USAGE
# php_exec filename
#
# This script is meant for viewing the output of php scripts in konqueror, without the need for a
# web server to handle all of the parsing and serving.
#
# Simply assign the application/x-php mime-type to execute this script.
#
# This script simply passes the first filename argument to php, saves the output to a temporary
# file, and calls any running konqueror instances to open the said temporary file.
#
# Caveats: One must go 'back' and reopen the desired php script through Konqueror in order to see
# updates.
# Reloading will generate a 'file not found' type error.
if [ -n "$1" ] # Is there an argument given?
then
# Pass the first argument through php and save to a temporary file
php $1 > $1"_temp.html"
# Find the running instances of konqueror
INSTANCES=`dcop | grep konqueror`
# Call konqeuror
if [ -n "$INSTANCES" ]; then
# Parse the first instance
for FIRST_INSTANCE in $INSTANCES;
do
break;
done
# Use DCOP to tell the instance to open temporary php output file
dcop $FIRST_INSTANCE konqueror-mainwindow#1 openURL "$1"_temp.html""
fi
rm "$1"_temp.html""
fi |
|
|
Back to top |
|
|
|
|
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
|
|