Although PHP is NOT my preferred language for web application development, sometimes you just gotta.
I already have Eclipse and I use it mostly for Java. However, here's how I installed PHP development tools.
In Eclipse, go to Help --> Install New Software --> click "Add" to add a new site, for the name I just put "php dev tools" and for the site I put http://download.eclipse.org/tools/pdt/updates/release. Here's where I got that URL from: http://www.eclipse.org/pdt/downloads/ I think that PDT stands for PHP Development Tools.
Now you can go New --> Project --> Other and "PHP project" will be an option.
Then it will ask you if you would like to switch to the PHP perspective.
Now you can right-click on your new project and go New --> PHP File, say "helloworld.php".
At this point, you might be inclined to read the PDT User Guide, like me, only to find that the sections, "Preparing the Workbench", and "Creating your first PHP project" are blank. What the hell!
Well, PHP, perhaps you and I will always have a troubled relationship. But I will keep trying and I hope that can hold up on your end of things.
Moving on, I'll figure this out for myself.
Right-click on helloworld.php and choose Run As --> ah, ha! there is a new "PHP Web Application" option! But it doesn't work: "Page load failed with error: Could not connect to the server."
That's because we haven't created the server yet. So, let's go into Window --> Show View --> Other --> Servers. Then right-click in this view and choose New --> Server, then under Basic, choose "HTTP Server". For "Publishing Directory", Browse to your "htdocs" folder of the Apache installation on your machine, then go into the web folder for this specific project. I have a Mac, which comes with Apache installed by default. My user's folder is in /Users/myuser/Sites. Here's a handy link for setting up Apache + PHP on OSX Mavericks: http://akrabat.com/computing/setting-up-php-mysql-on-os-x-mavericks/.
Anyway, back in Eclipse type in the location where the PHP files should go where Apache can see them. Click through the rest to finish setting up the server.
NOW you can right-click on helloworld.php again and Run As PHP Web Application. This time, you see a familliar Apache Not Found message. Next we gotta set up so the PHP files are automatically copied from Eclipse into the htdocs folder......... and so far I have failed to get this working. So I will just manually copy the php files from the Eclipse workspace into the Apache htdocs folder for now. So annoying! I thought I could create a symbolic link from the workspace to the htdocs folder, but PHP files give me a 403 Forbidden. I made the "real" files in the workspace and the symbolic link in the htdocsfolder. Maybe I should try it the other way around.
Another thing you can do is right-click the PHP project --> Properties, then go under "Targetted Runtimes". This will take you to a screen similar to above (where you have to put in "HTTP Server" and "Publishing Directory". When I tried this the option I had set up above was greyed out. I don't know why.
When doing this, you will likely set up a whole bunch of Servers, most of which you won't need. How do you delete the extra ones? Find the Server tab in Eclipse, right click and pretend you're going to make a "New" server. In that window you'll get a link "Configure runtime environments" where you can remove the extras.
Eclipse / PHP links:
- Installation on Eclipse: http://robsnotebook.com/php_debugger_pdt_xdebug
- http://www.eclipse.org/pdt/help/html/running_php_web_pages.htm
- http://stackoverflow.com/questions/432162/does-anybody-have-a-development-staging-deploying-workflow-with-php-mysql (team workflow)
- http://ubuntuforums.org/showthread.php?t=1787976 (note to self, read this one again - bottom!)
- http://coolestguidesontheplanet.com/install-configure-apache-mysql-php-phpmyadmin-osx-10-8-mountain-lion/
- http://brianflove.com/2013/10/23/os-x-mavericks-and-apache/
- Symbolic links discussion http://stackoverflow.com/questions/4097946/whats-the-best-way-to-deploy-a-php-pdt-eclipse-project-to-apache-on-ubuntu
- OS X adding a user to a group (to give Apache user permission over the folder containing PHP files) http://superuser.com/questions/214004/how-to-add-user-to-a-group-from-mac-os-x-command-line
- NETBEANS PHP https://netbeans.org/kb/docs/php/project-setup.html#localServer
No comments:
Post a Comment