Browse local file outside the XAMPP\htdocs folder

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

Browse local file outside the XAMPP\htdocs folder

Postby jakemc » 07. February 2014 01:31

Hello,

I'm a longtime c# Microsoft .net developer who is very new to XAMPP, new to PHP, and Mac OS, so this might be a silly question. But I'm trying to figure out how to run a php file without having to drop a copy into the XAMPP\htdocs folder. If I just open the file in safari, i only see the php code itself. Of course, if I copy it to that folder then I can browse to http://127.0.0.1/myfolder/myfile.php and it works. It seems pretty archaic and cumbersome to have to copy my whole application to what seems like a system folder just to be able to "play" it. Or maybe i'm spoiled by Visual Studio in being able to edit code, run it, and debug it all in one IDE. Or maybe I'm using the wrong IDE, i'm using AptanaStudio3 which works pretty well otherwise. Hopefully, I've just overlooked a setting and will feel silly shortly.

I'm using XAMPP 1.8.3-2 on a macbook pro running OS X 10.9.1 Mavericks. I do have Apache server running, but unlike the PC version that I have running on my PC, it does not show any kind of PHP engine running. Maybe I don't have that installed??? I have not turned on MySQL or ProFTPD, but I've only turned on Apache.

Thanks in advance!
Regards,

JakeMc
jakemc
 
Posts: 2
Joined: 07. February 2014 00:25
Operating System: OS X 10.9.1 Mavericks

Re: Browse local file outside the XAMPP\htdocs folder

Postby Altrea » 07. February 2014 05:59

Php is a server side running script language. It gets compiled / interpreted on runtime. To make this possible it had to find the php interpreter.
Your browser does not know anything about php, server side running languages or running interpreters. It can only render HTML/CSS code or process client side scripts like Javascript. If you type an URL in your browsers address bar it will request that, if the address is a local file path it will try to render that file or show it as plain text.
Your Apache knows that requests for php files needs to be send through an interpreter and where to find that because that is configurated / implemented. But your Apache only processes URL requests and need to be able to route an URL to a file path to find that file. That is why the file needs to be saved to a place Apache expect to find it.

I know it is a different world for a C#.NET programmer, but you should try to accept the differences instead of trying to change it to be more likely the .NET world.
Use a good IDE (like phpStorm, Zend Studio or Eclipse PDT) for programming, that will make your live a lot easier. You can configure local servers, php interpreters, debuggers, etc and don't need to switch between all that components manually. You can also define folder sync to have a local working directory, etc etc.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8293
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Browse local file outside the XAMPP\htdocs folder

Postby jakemc » 08. February 2014 05:31

I guess that makes sense. I guess I just need to find the right IDE for debugging. I'll look into the ones you recommended.
Regards,

JakeMc
jakemc
 
Posts: 2
Joined: 07. February 2014 00:25
Operating System: OS X 10.9.1 Mavericks


Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 5 guests