Setting up your workstation for web development
From Joomla! Documentation
(Redirected from Setting up your workstation for PHP development)
This article or section is in the process of an expansion or major restructuring. You are welcome to assist in its construction by editing it as well. If this article or section
This article provides detailed instructions for setting up your workstation as a PHP development environment, not only for Joomla! it also should work fine for PHP development in general.
Note There are many possible configurations for doing PHP development environments. Any environment that supports the basic AMP stack (Apache, MySql, PHP), Subversion and/or Git should be fine.
Choosing a code editor
The PHP language code represented just by plain text that can be edited with simple text editors like:
- Gedit (opensource code editor for linux)
- Notepad++ (opensource code editor for Windows)
- Apple textEditor (Apple's basic text editor)
- Komodo Edit (Komodo Edit is a fast, smart, free and open-source code editor for Windows, Mac and Linux)
But when you are about to work in more advanced and complex projects and need some coding assistance there is a handful of development tools called IDEs (Integrated Development Environment) these are some of them:
- Eclipse IDE (opensource cross platform IDE)
- Netbeans IDE (opensource cross platform IDE)
- UltraEdit IDE (closed source cross platform IDE)
- Aptana IDE (opensource cross platform IDE)
- Shiftedit IDE
- Geany IDE (opensource cross platform editor with basic IDE features)
- Komodo IDE (cross platform IDE)
As new emerging technologies we got other kind of editors available as an alternative to the traditional simple editors or desktop IDEs applications, among them we got:
- Web based IDEs: editors that runs on the web
- Cloud based IDEs: editors that runs on the cloud
- Browser based IDEs: editors that runs on your browser
- Cloud IDE (Google chrome extension)
- Cloud9 (Google Chrome extension)
- ShiftEdit (Google Chrome extension)
- PHPanywhere (Google Chrome extension)
To empathize some of the advantages of the use of IDEs over simple text editors we got:
- Some IDEs integrate and/or let you integrate assistive functions to develop code such as code completion, re-factoring, templates, advanced search/replace, syntax check, syntax coloring and more
- Some IDEs can analyze the project as a whole and build a map of relationships between the classes in use in your project giving you the opportunity to explore the project in a more comfortable and coherent way
- Some IDEs can analyse the current file under edition and give you a map of the different variables, functions and classes present on the file as a shortcut to navigate through the content
- Some IDEs integrate and/or let you integrate PHP debugging client under the same tool
- Some IDEs integrate and/or let you integrate several kind of source code revision control clients under the same tool
Some of the advantages of simple text editors are:
- This kind of editor are usually lightweight
- Some of these editors are great to do quick editions
- Some of these editors provide syntax coloring and basic code completion
All these options can be used for the development of PHP projects, but for this article we are going to focus on Eclipse IDE, feel free to add more alternatives and document them in the following list.
- Configuring Eclipse IDE for PHP development
- Configuring Netbeans IDE for PHP development
- Configuring UltraEdit IDE for PHP development
- Configuring Komodo Edit for Joomla Code Completion
Choosing a web server
To develop and test our PHP projects we need to execute the code in a web server capable of interpret PHP code and send the output to our browser, is good to know that we have a nice range of opensource tools to deploy a PHP webservers for our development environment such as:
- LAMP (AMP stack on Linux)
- XAMPP (Cross platform AMP stack implementation)
- WAMP (AMP stack for Windows)
Also there is other commercial closed-source options such as:
- IIS (Microsoft webserver, the PHP and MySQL services got to be installed manually)
- [Microsoft's Web Matrix] which installs a development platform for working on Windows.
All these options can be used for the development of PHP projects, but for this article we are going to focus on LAMP server for Linux and a XAMPP server for windows, feel free to add more alternatives and document them in the following list.
- Configuring a LAMPP server for PHP development
- Configuring a XAMPP server for PHP development
- Configuring a WAMP server for PHP development
- Configuring an IIS server for PHP development
Choosing a Debugging tool
Debugging tools are quite useful when you are developing a PHP project and you want to study how your code behave step by step on each executed line of your code, also these debugging tools let you see the real values of variables and objects and set new values on the fly for testing purposes, you can also create expression to check the outcome of them without modify your code.
Old school and hardcore PHP programmers don't fraternize much with these kind of visual tools and they prefer to debug their code the old way using php:var_dump and other methods to display and analyze the output of the PHP code, is up to you what kind of tools you want to implement in your development workflow.
There is several alternatives for PHP debugging, some of these are:
- Xdebug (opensource debugging service for PHP).
- Zend Debugger (commercial debugging service for PHP).
To empathize some of the advantages of the use of this kind of debugging tools we got:
- You can stop (freeze) the execution of your PHP code any time placing a breakpoint.
- You can inspect the current value of variables and objects without dumping the content.
- You can execute the code step by step all the way from the beginning of the PHP code to the end of it and study how your application behaves under certain circumstances.
- You can set or modify the value of variables and object on the fly and see the results of your changes without modify the original code at all.
All these options can be used for the development of PHP projects, but for this article we are going to focus on Xdebug, feel free to add more alternatives and document them in the following list.
Choosing a Version Control System
Don't you hate when you are coding and suddenly by accident you just deleted a big chunk of text and there is no backups of that file to restore those important lines of code?, don't you hate when you are working with 2 or more developers in a project and everyone have a different copy of the project then comes the day of merge all those changes in one final project but everything goes wrong or the project does not want to run properly because someone did just overwrite some of your files?, for all this problems and many more exist some nice tools to bring you the solutions you need, some of these tools are:
- GIT (Is a distributed revision control and source code management)
- SVN (Is a software versioning and revision control system)
A Version Control System also known as VCS is a very important tool in the development of software projects, this tools keep track of all the changes you made in a file over the time, they also provide mechanisms to avoid version conflicts when 2 or more developers have made changes in the same files, another nice feature is that you can navigate back in time through the history of changes of a file and revert undesired changes if you want, tools like this make possible collaborative projects with thousand of developers around the world such as the Linux project were lot of people are constantly editing the project files every day and all the merging and revision process of thousand of files is automated by the VCS. Consider yourself some time to learn how to use this important tool.
All these options can be used for the development of PHP projects, but for this article we are going to focus on GIT, feel free to add more alternatives and document them in the following list.
Choosing a project build system
To read the full definition of a project build system you can go here but in short, the project build systems help you to automatize those tedious and repetitive tasks that developers got to do in several stages of the development of a project, some of this tasks are:
- Compiling source code
- Packaging (such as creating installers or final compressed files of individual libraries)
- Running tests
- Deployment to production systems (such as automatic upgrades and/or installation)
- Creating documentation and/or release notes
Looking at project build systems from another point of view we can say they are a tool to automate complex tasks or little tasks such as:
- Move a file from one place to another
- Compressing a folder with several files
- Upload a final build to a server
- Update the content of files such as XML files or some comment sections of PHP files to print the version of the last build
A simple thing like the development of a Joomla! extensions such as a simple module could need the use of a project build system to gather all the information dispersed about the module in the Joomla! folder structure and put it back to the typical package structure of a module package with a simple build command, this could save you several minutes and headaches when you try to build a module or any extension manually and misplace a file or skip one of then in the final package. Consider your self some time to learn the proper use of project build systems and make them part of your regular development workflow.
Exist several options for project build systems out there, some of those are:
- Phing Project (Build tool that uses simple XML build files and extensible PHP "task" classes to describe the build process)
- Apache Ant (Build tool that uses simple XML build files to describe the build process, it needs JAVA to run)
All these options can be used for the development of PHP projects, but for this article we are going to focus on Phing, feel free to add more alternatives and document them in the following list.
Choosing a project management system
Any decent project is complete without a project management system, this applications helps developers, users and community to the planning, organize and administrate the resources of the project such as time, developers, goals. More sophisticated and complete project management systems comes with issue tracking, documents & files management, wiki, forums, blogs, SCM integration and more, some of those tools are:
- Web based applications
- Cloud based applications
- Desktop based applications
Some of these options are tools to control the administrative part of a almost any project like planing, resources, etc, but not all the features like code tracking, bug tracking and issue tracking, other tools like redmine got lot of features even more that some small projects needs and online services like Github gives you lots of features for free without the need of setting up a server to install the project manager.
All these options can be used for the development of PHP projects, but for this article we are going to focus on ProjectFork, feel free to add more alternatives and document them in the following list.
- Configuring ProjectFork to administrate a PHP development project
- Configuring GitHub to administrate a PHP development project
- Configuring SourceForge to administrate a PHP development project
- Configuring Redmine to administrate a PHP development project
Considerations for your future as developer
Whether you plan or not to develop extensions for Joomla or any other PHP platform, this articles gives you nice initial vision on how configure your workstation and what tools you can use to organize yourself and your project, this are very important topics to study in detail to level up your professional skills.
There is no excuse to not use one of these tools explained in this article, not even for small projects, you should always try to be as much professional as you can and you will see that the amount of problems, building, bug tracking and other common an repetitive issues will be easy to manage with your client and coworker, imagine yourself creating copies of your project over and over, and no one have a control to which one is the last version, imagine your client sending you emails or chat messages constantly to tell you about a simple bug he/she found or just want to do a modification of some specific feature like the color or the size of a html object, that is a total pain, you better configure yourself project management system to keep all those bugs ans issue well organized.
As a final note for this article here are some other important consideration for your future as developer:
- Do not use Sneakernet to handle the documents of your project
- Consider the possibility of host your project in the cloud with Github, SourceForge, Bitbucket and others, this services comes with a lot of nice features like, blogs, issue trackers, version control, forums and more.
- Subscribe to security forums or security mailing lists
- Collaborate with the documentation effort gives you direct and indirect benefits at short and long term during your career as developer
- Keep an open mind and always give a try to different and new alternatives for tools as much as you can to helps your self gain knowledge and confidence when you need to chose a tool or solve a problem
- Consider your self to invest some of your time as a novice developer to help others in support forums or support IRC channels, this will give you an invaluable experience to learn how to deal with real people with real problems from different parts of the world, and who knows some of them could be or will be your future clients, in other words this is a win win situation you win experience knowledge and future clients
- Conserve your mouth 'Ecologic', is a bad habit from some novice developers to say this or that tool 'sucks' or 'stinks' because they don't know how to use them correctly, is not fair says that a Jackhammer 'sucks' because is really hard to nail a photo portrait to the wall with it, so try to not emit 'destructive' comments if you don't really understand how the tool operate
Documentation support and discussion
For suggestions, observations, report a bug in the code or errors in the configurations or procedures described in this document feel free to post a message in the discussion page or post a message in the following forum boards