| Developing PHP with eclipse PDT |
|
PHP development in eclipse As a java developer, I have allways used eclipse to develop my applications. Although it is quite a "heavy" program in terms of memory and processor, it is my all time favourite. For developing php I have allways used free tools that would do syntax highlighting, but was allways missing the auto-completion that eclipse provides for java. I recently learned that it is possible to develop PHP within eclipse. This article is about my first experiences with this tool. The installationThe eclipse project for php developers is called PDT: http://www.eclipse.org/pdt/ On this page you can find everything you need for your installation. Once you come on the downloads page, you can choose from several releases. I chose the most recent one. Now there are several installation options:
I have chosen the all-in-one package for a fast installation. The installation is as easy as to install eclipse. Download the package, extract it in a chosen folder and run it! The other two installations shouldn't be much harder as most installations in eclipse are very convenient as you just extract the files and then it should work. In order to run any php project, you will of course need a web server such as wamp (http://www.wampserver.com/) installed and running. First overviewThe easiest way to get started is to create a workspace into the www folder of you webserver. (example: c:\wamp\www\eclipse) This will allow us to test our applications very easily. In order to get started, we need to create a php project. Go under File->new-> PHP project Enter a project name, click finish and say yes when you are requested to enable the perspective associated with php. For now, it's looking great... Let's see what we can do! I created a test class with some code that does the typical printing of hello world. Straight away, I appreciate the auto-completion suggestions for my variables and method calls... This is actually the reason why I wanted to change to eclipse in the first place! This is what my environment now looks like: Let's see how we can run our code... Installing a debugger
The Zend debugger is a free available extension. Let's try that one. It can be found here: http://www.zend.com/en/community/pdt#debugger I chose to install it via the update manager of eclipse.
Now you have a debugger installed, you can run you php file by right clicking->run as->php script. The output will be shown in the console as it would in java. Note that this output is purely text so if you are generating some html, you won't be able to see it from here. If you want to do some debugging, it works the same as in java: insert some breakpoints, choose the debug icon on the toolbar and launch your class. Running your code inside your web serverOf course, you can access your code through http://localhost/eclipse/project_name/file_name.php But we can also launch it from inside eclipse. Right click on the class you want to execute, run as->PHP web page Accept or change the link to the file (make sure that the path to the file is correct). That's it ! it should be running now!
Powered by !JoomlaComment 3.23
3.23 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved." |
