Web Development

You are here

Make vim default editor for git and ubuntu

To make vim the default editor for Git or your entire operating system. Firslty make sure that vim is installed and then you can chose one of the options below.

 

If you want to change Git default editor only use the following

$~ git config --global core.editor "vim"

If you want to change the default editor across the whole installation use this command

$~ sudo update-alternatives --config editor

Installing Symfony 2 because of Drupal 8

Now that Drupal 8 is starting to use Drupal components I thought that it would be in my best interest to try installing Symfony 2 and read up on its components and how they work. From the start what you find is that it does nothing even after you have created a Bundle. Yaml is completely foreign. But after going through the Symfony 2 Cook Book things started to make sense. I love the command line tools and composer wow and to see it all in OOP, sorry Drupal but it just makes so much more sense and I don't feel like I need to belt my head up against a brick wall and then jump off a cliff.

Apache redirect examples

Redirect rules in apache .htaccess are very useful. Below are some examples that allow you to achieve some simple tasks that I use on a regular basis.

Testing to see if htaccess is working?

The best thing to do in this circumstance is find or create a file called .htaccess in your root directory and add a whole lot of characters and then open your browser. Navigate to the url in the browser. Refresh the page and you will either see an error from the web server or you'll get a blank page.

How do I access or get object properties from a class in PHP?

After getting an StdClass() from a PDO database call you need to sort the data in some way, at times however you only need to access one property of the object. You could place the object into a foreach loop and search the object but if you know the property that you want to access there is an easier way.

Using Ternary Operators in PHP

The use of ternary operators in PHP is fantastic and even though I always forget to add the : when writing a ternary operator it is great to have in the arsenal when writing some PHP. As a complement to an if else statement when used in the appropriate way can really assist in PHP development and should not be over looked. I always like to use it when an if else or if statement will fit on one line.

Installing Xdebug on Ubuntu

Need to install xdebug on Ubuntu so you can test that really cool PHP web app that will wow users for a decade? The first thing you need to achieve that goal is have Ubuntu installed and the lamp stack ready to go. Next open the terminal and install xdebug by using the following command.

~$ sudo apt-get install php5-xdebug

Next open the php ini file on Ubuntu so that we can ensure that xdebug is being seen by the PHP engine, again from the terminal ensure you have vim installed or you can use gedit and open php.ini file

Drupal module URL shortening service

I wanted to shorten a url for social media reasons but all the providers of url shorteners have one issue, they don't allow you to keep your brand. But that does not affect the Drupal community there is a module called shurly it allows the user with the right permissions to create a shortened URL

 

How to use Drupal module Shurly

To use this module after it has been enabled is really easy, just log into your Drupal installation and then navigate to http://<your url>/shurly

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

Pages