executing php files thru safari

andehlu

this modern love
Im not 100% sure how I did it in Panther but I could open php files and have them execute right thru safari (open with not thru localhost)....now i have MAMP installed on tiger, when I try to open php files thru safari they dont execute..... any ideas on how to do this? I find it a pain to launch MAMP and move everything to my htdocs directory....i did it once so....

thanks.
 
This might sound like a silly question, but have you turned on PHP? Or installed the new version?

I don't think Safari has PHP as a registered file-type until you do.
 
I bet you ten bucks that you never were able to execute PHP code through Safari. Safari doesn't run the code through the PHP enginge, it will just read it. No execution. You're not remembering correctly.

What you might have done, is opening a PHP document in an editor like HyperEdit, that does take advantage of the PHP engine, and is also capable of rendering html in a preview pane.

That will still work, so try that. You'll find it here:
http://www.tumultco.com/HyperEdit/
 
elander, Safari parses PHP all the time, local or otherwise.

Put you do need to install (or at least activate) PHP with the #-removing in httpd.conf
 
texanpenguin said:
elander, Safari parses PHP all the time, local or otherwise.

Put you do need to install (or at least activate) PHP with the #-removing in httpd.conf

Bull. It READS the code, and presents it as is, but it does not PARSE or EXECUTE. It will parse HTML if it's present in the code, but it will NEVER parse PHP on its own.

You could of course create a Safari plug-in, that would send the PHP code through the php or Zend engine, and then present the result to Safari. Possibly a good idea for testing local files, but I wouldn't recommend it, since it would also parse files received from a misconfigured server.

As for parsing remote code, what are you thinking? A web server correctly configured to handle php-files never sends php code to the browser. It is parsed and executed on the server, and the results (HTML, XHTML, XML, text, images or other document types) are sent to the browser. It never sends any PHP code what so ever. Never.

HyperEdit, on the other hand, can use any PHP engine that you have on your system (e.g. "/usr/bin/php" for the default or "/usr/local/php5" if you've installed PHP 5) to parse and execute the php commands. You can choose which one to use in the settings. The results that come back from the chosen engine are then displayed in a "preview" pane next to the editing pane.

Safari does no such thing. You'll get the same results as if you opened the document in any text editor.
 
elander...obviously safari is not capable of rendering php on its own. What i was saying is that somehow I had safari open php files directly and use the php module to render. And pls dont tell my I am not remembering properly. The whole reason I made this post was cuz I KNOW i was doing this, and tried to see if anyone knew how to do this.
 
Here is a link to a page describing one way of previewing php code in the browser: http://tinyurl.com/dkg5e

This is as close as I can come to what you're looking for. I've never heard of a way to route php through the php parser via the file:protocol as you (andehlu) suggest in your post. I haven't ever heard of a plugin that would let you do it either, and I have searched pretty hard for it.

[EDIT] Maybe you could try this: use terminal to send the document to php, and pipe the result to Safari? Maybe use a droplet (AppleScript or Automator perhaps) to do it for you? [/EDIT]

As for not telling you your memory is deceiving you: I've been working with php for almost eight years now (since the betas of PHP/FI 2.0), and I've never even heard of anything remotely similar to what you describe. I've consulted with a bunch of colleagues on the matter also, and I'm afraid they all come down on my side of the fence...

However, it is entirely feasible to create a plugin for Safari that will do what you want. If you really think it is worth it, you might want to try that.
 
I was using the Server Logistics binaries of apache/php/mysql when I was able to do this..... does anyone run these binaries still that could test this?
 
You can do "PHP filename.php" on the command line to have PHP parse the script properly. You'd have to either output that to a file or pipe it to the browser... not sure how to do that in OS X just yet. Some editors probably do this (BBEdit doesn't though).

Directly accessing a PHP script from any browser will just result in the text of the file in the web browser. Browsers only understand the client-side aspects of a page, not the server-side scripts. (Unless, like someone mentioned, there's a plugin or something that does the parsing for it.)

Regardless of which PHP package is installed, the only way to get Apache to parse and serve the PHP scripts to the browser is to access the page using http:// which would require going either through localhost or a virtual host setup to point to the folder that contains the files. Any reference using file:// does not go through the web server.
 
First of all, browsers don't "execute" php... ever. the Apache web server and PHP engine work together to do that.

By accessing the file directly from the filesystem you are skipping Apache... thus no execution and rendering. Yes there are tricks to execute the code, but why %^#$%^ bother?

Why not just make your life 10,000% easier and run it through Apache via http://localhost/ or http://127.0.0.1/ ?
 
Back
Top