How to Set Up a Webdev Environment
- 1 Setting up Your Local Webserver
- 2 Setting Up Eclipse
- 3 Optional Plugins
- 4 Your First Project
- 5 Debugging Your Projects With the xdebug Plugin
- 6 Resources
- 7 Further Question
Setting up Your Local Webserver
Before you can do local development on Web products, you need a web server that supports PHP 5.3. The standard here at ISoft is Apache 2.2.17 in conjunction with PHP 5.3.5, and a MySQL connector or server of some kind. In the future, we will theoretically support IIS, since some clients use it on their Windows boxes, but this Wiki currently only covers the WAMP stack.
Installing WampServer 2
The easiest way to get all of this up and running from a clean install is with WampServer2, which can be downloaded and installed here.
If you've already got some installed components, you'll have to install some things separately, but none of the individual components should be too difficult to get working.
You can find the configuration file for httpd by going to the httpd folder (wherever you installed it), then conf/httpd.conf.
Enable the following modules:
The configuration file for php is most likely located at the root of your php directory, named php.ini.
Configure the following:
- memory_limit = 128M
- error_reporting = E_ALL | E_STRICT
- variables_order = "ECGPS"
- register_globals = Off
- magic_quotes_gpc = Off
- extension = php_fileinfo.dll ; uncomment it
- extension = php_curl.dll ; uncomment it
Installing the xdebug Plugin for PHP
This plugin is needed in order to step through your PHP scripts in the IDE of your choice (read: Eclipse). You can find step-by-step instructions for properly downloading and installing the xdebug plugin here. This wizard tailors its instructions to your particular setup.
Setting Up Eclipse
The Foundation: Eclipse, Classic Edition
We're going to be starting from the Classic Edition of Eclipse, which can be found at the Eclipse project homepage. Alternately, you can grab Eclipse for PHP Developers, but if you get that version, and you want Java or other languages, you'll have to add them yourself later.
Eclipse doesn't "install" per se... Instead, it unzips into its own folder on your local hard drive. I unzipped mine into C:\Program File\eclipse. You will have to create any Start Menu or Quick Launch shortcuts yourself, but eclipse is ready to go out-of-the-box. All you have to do when you run it for the first time is specify a workspace folder, and the default is usually fine.
Standard Eclipse Plugins
The Subclipse plugin is a powerful tool that integrates subversion with Eclipse. This plugin is optional considering some developers may already be comfortable with Tortoise SVN; however, if you want to integrate subversion into your IDE, subclipse is a very slick way to do it.
To install Subclipse, go back to Help->Install New Software. In the Work with box, enter "http://subclipse.tigris.org/update_1.6.x" and click Add. Give the repository a name like "Subclipse repository," click OK and wait for the update list to refresh. From the update list, check off the boxes for Core SVNKit Library and Optional JNA Library. From the Subclipse submenu, choose all of the required items. Click through the installer.
Restart Eclipse if necessary, and you should now be ready to work with SVN from inside the IDE.
Installing Quantum DB
Quantum DB is also optional, since you might already be used to SQLYog; however, if you'd like to browse and manipulate databases from within your IDE, it's a powerful, competitive tool. The update site for Quantum DB (which can be added in similar fashion to the update site for Subclipse above) is http://quantum.sourceforge.net/update-site. Select all Core and Import-Export packages, then click through the installer.
Connecting to a Database
To connect to a database, you will need MySQL Connector/J, which can be downloaded from http://dev.mysql.com/downloads/connector/j/. Once you have the jar file somewhere on your hard drive, go to the Quantum DB perspective (Window->Open Perspective->Other->Quantum DB), right click inside the Database Bookmarks view and choose "New Bookmark..." Click the "Add driver" button, click the "External JAR file" button, browse to the Connector/J .jar file. Click browse to choose a driver object and choose the top one (com.mysql.jdbc.Driver). Click OK.
Back in the New Bookmark dialog, choose MySQL-AB JDBC Driver, click Next, and fill in the database details. Click Next, choose a name for the database, and you're almost done. The final step is to change a single setting on the database bookmark that will fix a compatibility issue between MySQL Connector/J and the way our databases are formatted.
Right click the new bookmark and choose Properties. At the end of the Connection URL, paste the string "?zeroDateTimeBehavior=convertToNull" and click OK. You should now be ready to connect to your database by double-clicking the bookmark, and you can browse and run queries in much the same way as you could in SQLYog. Take some time to experiment with the new interface.
Your First Project
Creating a Web App Project Without Subclipse
If you have the Subclipse plugin, you can check out the code for your project at the same time you create your project. Otherwise, you're better off checking out your code to Webroot before you create the project in Eclipse. Webroot can be determined by looking at the output of phpinfo(). In WampServer2, you can view the output of PHPInfo by clicking on the tray icon, choosing Localhost, and following the PHPInfo link in the webpage that comes up in the browser.
Creating a Webapp Project With Subclipse
To import code from the repository using the Subclipse plugin, right-click on the name of your new project in PHP explorer and choose "Share Project" from the Team submenu. Choose SNV, click Next, use existing repository location (https://svn.isoftdata.com/Web), click Next. To find your specific product/branch/codebase in the repository, choose Use specified folder name, and click Select to browse to your code. Click "Finish", then "Next", and your codebase will be checked out into your project. You can perform SVN operations on your new project by right-clicking on a file (or the project name) and choosing from the Team submenu. When committing, you can see a graphical diff by double-clicking on any files that have changed.
Debugging Your Projects With the xdebug Plugin
To step through the PHP in your project, you should create a Debug profile by visiting Run->Debug Configurations and double-clicking the PHP Webpage configuration. This will create a new configuration called, appropriately enough, "New configuration." (I recommend renaming it to something useful, like, "EnterpriseLX Debug"). For your Server Debugger, choose XDebug. Your PHP server should be the default PHP webserver. Under "file", browse to the index file for your project; make sure "Break at first line" and "autogenerate" are checked (unless you have an unusual URL for your project.) You may want to add this debug configuration to your favorites by checking Debug in the Display in favorites menu box on the Common tab. Once you've got everything set up the way you want it, click "Apply" and then "Debug."
You can find the files used for this installation procedure on \\file\ToolsUpdates\WebDev.
Now you have all the tools you need to create and edit projects, check them in and out of the repository, and debug them on your local development computer. If you have further questions, Eclipse has lots of online documentation, and you can always talk to your senior developer as well. Good luck, and happy coding!