Setting up your workstation for web development
From Joomla! Documentation
(Redirected from Setting up your workstation for PHP development)
This article provides detailed instructions for setting up your workstation as a PHP development environment, not only for Joomla! but also for PHP development in general.
Note There are many possible configurations for 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)
- Visual Studio Code
The best text editors out there today are among:
- Sublime Text
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)
New technologies are available as an alternative to more traditional editors or desktop IDE applications, some of them are:
- Web-based IDEs: editors that run on the web
- Cloud-based IDEs: editors that run on the cloud
- Browser-based IDEs: editors that run on your browser
- Cloud IDE (Google chrome extension)
- Cloud9 (Google Chrome extension)
- ShiftEdit (Google Chrome extension)
- PHPanywhere (Google Chrome extension)
Some of the advantages of using IDEs over simple text editors are:
- Some IDEs integrate assistive coding functions 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 being used in your project, allowing you to explore the project in a more comfortable and coherent way
- Some IDEs can analyze 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 clients under the same tool
- Some IDEs integrate and/or let you integrate several kinds of source code revision control clients under the same tool
Some of the advantages of simple text editors are:
- Usually lightweight
- Great for making quick edits
- Some of these editors provide advanced features such as syntax coloring and basic code completion
There are many options available to develop PHP projects. This article focuses 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 test and develop PHP projects we need a web server which can interpret PHP code and send the output to our browsers.
Open source options include:
- LAMP (AMP stack on Linux)
- XAMPP (Cross platform AMP stack implementation)
- WAMP (AMP stack for Windows)
- Bearsampp (Full portable dev stack for Windows)
Closed-source options include:
- 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
- Configuring Bearsampp for php development
Choosing a Debugging Tool
Debugging tools are useful for developing a PHP project. You can study how your code behaves step-by-step as it executed, see the real values of variables and objects, set new values on the fly for testing, and create expressions to check the outcome of them without modifying your code.
Advanced PHP programmers may debug their code using traditional methods such as php:var_dump to display and analyze the output of the PHP code.
Some options for PHP debugging are:
- Xdebug (opensource debugging service for PHP).
- Zend Debugger (commercial debugging service for PHP).
Some of the advantages of using debugging tools are:
- You can stop (freeze) the execution of your PHP code any time by 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 throughout execution to study how your application behaves under certain circumstances.
- You can set or modify the value of variables and objects on the fly and see the results of your changes without modifying the original code at all.
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 you accidentally delete a big chunk of text and there are no backups to restore those important lines of code from? Don't you hate when you are working with two or more developers on a project and everyone has a different copy of the project and when it comes time to release the program everyone is on a different page? For all these problems and many more there exists a number of version control systems:
- GIT (Is a distributed revision control and source code management)
- SVN (Is a software versioning and revision control system)
A Version Control System (VCS) is a very important tool in the development of software projects. It helps you to keep track of all the changes you made in a file over time. It helps you to avoid version conflicts when two or more developers have made changes in the same files. It allows you to review a documents history to see what changes have been made, when they were made and who they were made by.
Tools like this make collaborative projects with thousands of developers around the world, such as the Linux project, possible. Take some time to learn how to use this important tool.
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 automate tedious and repetitive tasks such as:
- Compile source code
- Package (create installers or final compressed files of individual libraries)
- Run tests
- Deploy to production systems (such as automatic upgrades and/or installation)
- Create documentation or release notes
- Move files from one place to another
- Compress folders with several files
- Upload a final build to a server
- Update metadata within files, such as updating the version fields in XML or PHP files
For example if you're developing a Joomla! extension you could use a project build system to gather all of the information about the modules in the Joomla! folder structure and create a properly structured package with a simple build command. Otherwise the user would need to map these dependencies manually and create and move the files accordingly.
Take some time to learn the proper use of project build systems and make them part of your regular development workflow.
Some options for project build systems 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)
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 isn't complete without a project management system. Project management systems help developers, users and community to plan, organize and administer resources such as time, developers, tasks. More sophisticated and complete project management systems comes with issue tracking, documents & files management, knowledge bases (wiki), forums, blogs, supply chain management (SCM) integration and more. Some project management tools are:
Some of these options listed are general project tools for the administrative part of a project like planning, resources, etc., while others contain features like code tracking, bug tracking and issue tracking. Redmine has a lot of features for small project needs and online services like Github give you lots of features for free without the need of setting up a server.
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
If you're planning to develop extensions for Joomla! or any other PHP platform this article gives you nice initial vision on how to configure your workstation, and tools you can use to organize yourself and your project. These tools are very important topics to study in detail to level up your professional skills.
There is no excuse to not use one of the tools explained in this article, even for small projects. You should always try to be as professional as you can and you will see that the amount of problems, building, bug tracking and other common and repetitive issues will be easy to manage with your client and coworker. Remember that all these tools exist to save you time and trouble. While it may seem difficult to learn each tool and find a good workflow, just imagine the alternative disasters you are avoiding with this wise investment of time and energy.
Some additions considerations for your future as developer:
- Do not use Sneakernet to handle the documents of your project.
- Consider the possibility of hosting your project in the cloud with Github, SourceForge, Bitbucket and others. These services come with a lot of nice features such as blogs, issue trackers, version control, forums and more.
- Subscribe to security forums or security mailing lists.
- Collaborating 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 try different and new alternatives for tools as much as you can to help yourself gain knowledge and confidence when you need to chose a tool or solve a problem.
- Consider investing 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. Someday one of of them could be one of your future clients. In other words this is a win-win situation. You win experience, knowledge and future clients.
- Trash talk is a bad habit. Some novice developers start by saying this or that tool 'sucks' or 'stinks' because they don't know how to use them correctly. It is not fair says that a jackhammer 'sucks' because it is difficult 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 operates.
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: