Seasoned PHP programmer toolkits

Seasoned PHP programmer toolkits

PHP has grown a lot in the past decades and is becoming one of the emerging programming languages. There are still problems with it of course, phpsadness but I would say some of those problems can be easily avoided using a better programming standards.
I have compiled some basic tools/methodologies that we should at least know them to be a good PHP-abiding citizen. Some of the points are applicable to being a good programmer in general.

Version Control Systems
It is almost a must to know one basic versioning system. I would say it is good to have a knowledge of distributed versioning system. Here is a discussion regarding the central versus distributed versioning systems Difference between version systems
From the DVCS I have an experience on mercurial and git and I would say git is better.
Why using VCS? They become handy wheather we are working in team or solo programmer. Some examples:
-when the release becomes really creazy and we want to go back to the earlier solid version(checking out older revisions)
-To save the current working progress and be able to look on work another revision (stashing)
-To be able to search revisions based on comments of the commits we have
The above are some of the most commonest things we use day today without mentioning being able to work from different computers and other minor routines.

Dependency Manager
Composer has become a common inclusion on most of the frameworks for managing the depencies on the progect.
You know when you are working on a project it would be dependent on a lot of libraries. Some of them from third parties, some from github, some from PEAR… well how are we going to manage all these dependencies with out a headache? Composer!
Using composer.json file, you will be able to list all the dependencies you need for the project and it will cache it locally. So next time when you require the same dependencies it will be really fast to load it since it is loading from local computer not from remore githut repo or something.
What is the use apart from this? We will have a light weight application composed of the main business logic. All the third party stuffs will be loaded whenever they are needed using composer install command.
Other advantage is it will lock the dependencies using composer.lock file. By doing that we are assured that everytime when we are installing, it will using the lock file to fetch the dependencies.
You can get a lot of goodies that are prepared for composer from https://packagist.org/

Coding Standard
It is a vital part in coding in general – to have some coding standard. These days, lots of projects and even composer might require you to follow basic coding standards and for php, the defacto is ps-r one.
http://www.php-fig.org/psr/psr-0/
http://www.php-fig.org/psr/psr-1/
http://www.php-fig.org/psr/psr-2/
http://www.php-fig.org/psr/psr-3/
http://www.php-fig.org/psr/psr-4/

Caching
Caching is almost a must on most of high traffic sites. The concept is simple: it is faster to read the data from memory than from database/file. We do encounter a lot of data that do not change often like configs and hence it would make sense to put them on memory than reading them from database.
For this we can use Memcache/d http://memcached.org/
and Redis http://redis.io/
Both have driver for php and are widely used.
They allow object persistence through serialization so all the cost of reading from the database and constructing the object could be saved by tossing end-product object into the memory and use it.
*If you are working on Doctrine, it might not work well with those outside of its own caching mechanism. But that wont be the problem – just use its own!

Vagrant
I would say it is one of the best development tools. It is based on the concept of virtual machine. Can you imagine the problem you would face to setup a new machine for development, installing drivers for some of the packages, installing the language dependencies… with vagrant you would do all this only once. And you can use that same configuration again and gain. All you need to keep is some simple files containing your configuration.
Learn more on http://www.vagrantup.com/

IDE
This is totally personal. Some of us would be happy and productive by coding from vi or notepad others from eclipse.. the list can go on and on.
I have been on Eclipse, netbeans, vi, sublime..
By far I would say phpstorm is the best. http://www.jetbrains.com/phpstorm/ It would come with a month of free trial which will give you the chance to play with it.

No SQL Databases
We are all familiar with relational databases like mysql. With no-sql ones, the story is totally different. The are document based storage systems and they scale better horizontally.
To see it with and exmple, in a typical employee, department, company situation, we need three tables, assuming they are normilized in all forms, so to get the information of employeeA, there would be two joins involved. But in a no-sql database the data might look like, not exacly but, array (’employeeAId’=>array(‘company’=>companyInfoGoesHere, ‘department’=>DepartmentInfoGoesHere’));
You can see that selecting the database with single employeeId would give us an access to all the related data. Hence it scales horizontall.
As you can see, it might not be a solution for all cases. But it will definitely boost our performance with our old school relational database.
Take a look at http://www.mongodb.org/

I will write on
Debugging
Testing
Reviews
Workflows among others on my next blog.

find longest word in the sentence

Get maximum occurring character

Flatten nested javascript array

Implement Queue Using two Stacks – JavaScript algorithm

Update Node and npm on mac OSX

Tunneling to AWS instance using pem file

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*