Drupal, Silex, Symfony2, Ubuntu, Website Development

Adding .gitignore to a Git project

Having files that you don't need to commit but are important to your workflow on a project are always an issue. An example that keeps cropping up is the SCSS caches when you theme a website or your IDE leaves files in the root directory of a project and one that I always have is a temp directory where I can store information or data that is not necessary to the Git master or a remote repositories.

The way to get around Git complaining about these files is use .gitignore what it does it allows the developer to state what directories or files that are not to be seen by Git to add or commit to the repository. The code below allows you to add the .gitignore to an existing repository or one that you have created from scratch.

Read more

Creating a css style print sheet

How do you create a Print Style Sheet so that the users printer ink is not being run dry because of unnecessary images being printed? There are three things a developer needs to remember when building this for a client. The first one is What are the client needs?, yes that means a conversation, ok be brave you can do it. The next is setting up the style sheet css html link at the bottom of your html css links in the html document header tags, like the example below.

Read more

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
    large-branch-to-be-merge
    *master

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

Pages