PHP Development
I started my corporate career as a PHP Developer Trainee. My first day in the office. First thing first, I started with the selection of a good PHP editor. I googled for PHP editors and found some good editors, but each editor I tried missed on something, either heavy on system's resources or low on features or providing too much unwanted functions. Finally I settled down with VIM, for it was low on resources, and high on customization and quick editing shortcuts (most needed in PHP like scripting).
VIM proved good enough as my editor of choice, though I had just started using it in place of Emacs. It helped me with a lot of things, like:
- It offers a lot of quick shortcuts that are great for editing any PHP-script. Here is a list of the most commonly used VIM shortcuts
- Automatic Code Indenting, file saving, parenthesis matching, navigating the different PHP scripts while debugging.
- Viewing the PHP manual within VIM is a great help when you are looking for the PHP-functions their parameters, return types or even the correct name of the function. Just type "K" on the function name and it displays the documentation for the chosen PHP function.
- Here is my .vimrc
After developing some initial test PHP pages, I started my work on the live PHP websites. I learned about the smarty PHP templates and other details about the LAMP (Linux, Apache, MySQL and PHP) Platform. 1 week passed by and I started looking for ways of writing more efficient PHP scripts and reusing the code for performing common repeated tasks.
I learned following PHP tips:
- For those PHP websites that are database-driven (that most of them are), never connect to the mysql database on any individual PHP script. Rather create a separate script to connect to mysql and include thatscript in all your other PHP scripts.
- There is a lot of content repeated on a website like following the website layout on all the pages of the website. For all such repeated content,create separate PHP pages and include successively for every page.
- There are some repeated tasks as well. For example, displaying a list of records from a mysql table in an HTML table. For such things, I need not say that you should write functions in a separate script andinclude that script in a common file including all other includes.
- Try to reuse every line of code, that you have written. The idea is to minimize the time spent in doing repeat stuff. Moreover, it allows for single point of control over the content and reflect the change overthe complete website.
- Try using smarty PHP templates for all your PHP scripts, for they allow you to separate your code from your design. Even if you want to change the design later, you need not worry about the code. Moreover, smarty compiles each template page, so don't worry much about the performanceissues.
- Keep writing the documentation alongwith the code. It might appear as an additional task initially but proves to be a great help later when youread the code, believe me.
0 Comments:
Post a Comment
<< Home