Drupal, Silex, Symfony2, Ubuntu, Website Development

Install and test php_codesniffer on ubuntu

The PHP code sniffer is used to test the php code inside a php file to see if it meets the PRS-0 coding standard by default. It will test the following code types PHP, JavaScript and CSS. You can test any file from the command line.  Here is an example on installing and testing a file in Ubuntu.

Install PHP sniffer

Install the the PHP sniffer library using PRS-0 installation tool from the command line. Make sure that you have the root privileges (sudo) to install the new package

Read more

Add theme colors to Skype on Ubuntu

qtconfig configuration panelIf you want to change your Skype colors on Ubuntu you need to install qt4-qtconfig to do this open your terminal

~$ sudo apt-get install qt4-qtconfig

# Then you open the the qt4 manager
~$ qtconfig

Then you should get an image similar to what is below. Choose the appearance tap and select GUI style and I chose GTK so it would mimic my desktop.

Read more

Clearing Drupal caches

There are two ways to clear Drupal caches in a development environment. If you have drush installed from the terminal in the base directory of the Drupal website all you need to do is

~$ drush cc all

Or from the website gui all you need to do is from administration login press configuration

drupal 7 administration bar


The find performance link and press that

Read more

Drupal 7 preprocess tutorial adding variable to template

Understanding how to use preprocessor in Drupal can be very confusing. In this post we will explore how to achieve adding a variable to a node template file using the preprocessor hook (function). The first thing we need to create is the preprocessor function that has mandatory elements so that Drupal can see the hook (function) when called.


Read more

Drupal website is displaying 500 error or a blank page

Sometimes when moving a Drupal directory it will not copy all the files into the new directory. This can be caused by the way you copy the files and/or the permissions of the files on the webserver. I had a Drupal site that would work perfectly in its original directory but if I copied the Drupal 7 software into another directory I would get a 500 error or the browser would go blank. It took me a while to find the .htaccess was not copying into the new directory. As soon as I manually copied it across the website worked perfectly. 

Read more

Small smtp email server client on desktop

I need a small smtp client so I could send emails from my Drupal development machine. By using the package msmtp-mta this can be achieved. Firstly install the software, in this example Ubuntu will be used but from what I can see all Unix flavours have this package

~$  sudo apt-get install msmtp-mta

After it is installed then configuration is needed this can be by creating a file called msmtprc and adding some configuration.

After installing it we need to create a configuration file for it. Create a new file by opening vim or nano in the terminal

~$ sudo vim /etc/msmtprc

Then add the configuration you need to access your email smtp server. In this example we will use the Google smtp servers.

Read more

Git commands that we all need to remember

Git is fantastic but there are times when you need to find that odd command because you have stuffed something up. Here are some I use on those occasions, firstly open the terminal and navigate to the root directory of the Git repo.

You didn't want to commit that

~$ git reset --soft HEAD~1

I want to remove the second last commit

~$ git rebase -i HEAD~2

The master branch commits have moved ahead from my-current-branch when I first branched off

~$ git checkout my-current-branch
~$ git rebase master

I need to see the changes before I commit

~$ git diff [filename]

I need to see a users commits in the logs

~$ git log --author="username"

I want see what was committed

Read more

Git merge branch and commit individual files

Merging two Git branches and then commiting each merge file seperaterly looks easy except while in a merge Git will not let you do it. This howto will explain one way how to do it. Firstly go to the terminal window and move to the Git directory that you want to merge.  In this example I am going to merge the large-branch-to-be-merge into the master. Check out the master branch or the branch you want to merge like the example below.

~$ git checkout master
~$ git branch

The next step is to do the merge so that your wonderful new set of code will make the amazing changes to the software.

Read more

Drupal development environment

As a Drupal click monkey I came away from Drupalcon Sydney determined that I was going to contribute back to Drupal in some way. The big push in the community is to help with core development and the issue cues if you are able. But to a new Drupaler it is like looking at a mountain you need to climb and the only tool you have is a toothpick. I was listening to a Drupalise.me podcast that was discussing contributing back to the community, what I found interesting about the conversation was when they started to contribute it was like looking at a mountain to climb and only having a toothpick. I was not alone it seems.

Read more

Embed views into a Drupal node.tpl

On a project early this year I found the need to add a view of images between the content type body and comments. I looked at context module as I have used it before. But on reflection the website was very small and I didn't see the need to install an extra module for this small job.  After some research I found the function views_embed_views this allows the developer to add a view to a tpl file using code. This post shows you how you can do it for yourself. Firstly create a view that has a view page and view block and call the view anything you like. I have called mine views_embed_view (not very imagitive I know).  

Read more