Setup Advanced PHP Dev env on Windows (Part 2)
In Part 1 of this article, we already setup WAMP, PEAR and PHP Unit (edit: and Code Sniffer). If you missed that part, please go through Setup advanced PHP Dev-Env on windows part 1 first.
In this part, we are going to setup following:
XDebug: XDebug is used to debug PHP code and easily integrates with leading IDE like Netbeans.
Phing: Phing is PHP project build tool, based on Apache ANT.
Composer: Composer is new dependency management tool in PHP world.
(Edit) Code Sniffer: Check if your code is following standards. You can define your own standards.
Again to remind, this is not tutorial for given tools, we are just setting up the environment with these tools. Respective website is the good start point if you want to learn more about these tools. In future, I’ve plans to make a simple kick start tutorial for these tools but till then, go through official documents and Google for tutorials on these tools.
Setting up XDebug:
By default, WAMP comes with
XDebug come up with great utility which analyze the output of your PHPinfo and suggest easiest way to install/Upgrade. To use that utility, try following:
- Generate output of phpinfo()
Start wamp server and enter ‘localhost’ in the browser. Under tools, click on link phpinfo() - Copy the output of PHPInfo.
- Open http://xdebug.org/wizard.php, paste phpinfo() output in the given text area and press ‘Analyse my phpinfo() output’ button.
- Follow onscreen instructions to install XDebug.
Installing Phing:
Phing is a build tool for PHP projects. Although we might better like composer now a day but at times, phing become handy and easier tool. You can better decide which tool you want to use but for a good developer, it is always better to keep their dev-env loaded with all important tools.
Phing can be installed through Pear, similar to PHPUnit. We assume you have already configured PEAR during part one of this series but if not, first go through part one and install PEAR.
Open command prompt and type following commands
pear channel-discover pear.phing.info
pear install –alldeps phing/phing
Above commands will install phing and all its dependencies.
Installing Composer:
Composer is a dependency management system for PHP projects. What does it mean? Say you want to make a big project in PHP which will need many third party libraries. Thus these libraries will be dependencies for your project. Now if those libraries too need other libraries as there dependency. You first need to load those libraries means dependencies of dependency. But that might be an infinite loop. How much libraries will you download manually?
This is where composer might help you. You just need to care what libraries (dependency) you need and not for dependency’s dependency. You will tell composer what libraries do you need for your project and composer will download the libraries you need as well as their dependencies. Easy, isn’t it?
Installing composer depends on operating system. For windows, there is a nice installer which can be downloaded from http://getcomposer.org/Composer-Setup.exe
Download that file and just double click. Follow onscreen instruction to finish the installation.
Code Sniffer (Edit: added on October 6, 2013)
Now a days, Code Sniffer is also commonly used so that whole team follow same coding guidelines.
One of the biggest problem when big teams work on single project is different coding styles followed by different developers. This make code untidy, ugly and unprofessional. All enterprises have some coding guidelines and standards but how will you force developer to follow these coding guidelines, answer is Code Sniffer.
Even for new developers, it is always recommended to check your code with code sniffer. This will tell you at early stage how your code should look like. Its always best to develop good habits early while learning rather then later after getting embarrassed.
We already have pear installed. To install code sniffer, we just need one command:
pear install PHP_CodeSniffer
IDE
IDE stands for Integrated Development Environment, which basically consist of an editor with lot of utilities to help develop applications faster.
If you are new to programming, I’d not recommend installing and using any of the IDE. Students and new programmers, please skip this section and believe me, you will thank me after a year.
So not much in this section, I’m not going to tell how to install IDE (experienced programmers do not need this whole series. LOL). Purpose of this section is just to tell “Don’t install IDE for now”.
Editor
Okay we are not installing IDE for now but we still need any editor for coding. There are many editors available for windows however I prefer free and open source. Obviously being a student or new programmer, you would also prefer open source (free, if it is more important). There are quite a few open source editor and selecting one of them simply depends on person. I still use editor most of the time as IDEs are heavy weighted and huge. So when you need to quickly edit some file, editors are best. My personal preference is ‘Notepad++’ on Windows and ‘Kate’ on Linux, both opensource.
Well I was little too poor to own a Mac and Apple don’t care for poor. Now even when I can afford Mac, I hate Apple enough to remain away from Mac. If I can’t own it as a student, I obviously don’t need it as professional. Although this is my personal view, I could not resist writing it, sorry if you are Mac, iXyz lover.
You can go through different editor to pick your own favorite. However if you want to go with my favorite, believe me you won’t regret, installing notepad ++ is as simple as installing nay other software on windows. Just download it, double click installer and follow on screen instructions
Now you have everything you need to learn PHP and even developing huge corporate web applications in PHP. Practice and follow few of my other tutorial coming in next few weeks. Follow me ‘@kapilsharmainfo’ on twitter to keep track of coming tutorial and blogs which are going to student oriented for next few months at least.
Leave a Reply