Drupal 8 quickstart using composer

There are benefits of using installing drupal via composer.

composer create-project drupal-composer/drupal-project:8.x-dev myproj
cd myproj
# you can now add the required plugins eg
composer require drupal drupal/devel:8.*

Forget about drush, let us use the drupal console to install the site. This is the symfony way.

# let us configure the drupal command line
ln -s /path_to_myproj/vendor/drupal/console/bin/drupal /usr/local/bin/drupal
cd web
drupal site:install

Best Vagrant Lamp Stack

imagine setting up a vagrant and playing around with the vagrant config file. boots up and some libraries are not working, dependencies not working…etc.

thanks to scotch box, a vagrant lamp stack that just works


Docker Cheatsheet

Docker helps a lot in the dev process.

If using windows or mac, need to use a vagrant vm that allows nfs.


this will help u setup the vagrant. Once vagrant is up, shell in and run docker commands.

Remember to port follow all the relevant application port in virtualbox.

Here are some commonly used commands:

1. To build a new image from a Dockerfile

cd folder_containing_dockerfile
docker build -t username/app_name .

# if behind proxy
docker build -t username/app_name --build-arg http_proxy=x.x.x.x:port --build-arg https_proxy=x.x.x.x:port

2. View all docker images

docker images

2. View all containers

docker ps -a

3. Create a new container

cd website
docker run -d -p 8080:80 -p 8036:3306 -v `pwd`:/var/www/dir image_name
# if you use the --name option, you can specify the exact name of the container, else it will use some random cool name

4. Stop and start a container

docker stop containerid_or_name
docker start containerid_or_name

5. Remove an image

docker rmi image_name

6. Remove a container

docker rm containerid_or_name

7. Shell into a container

docker exec -it containerid_or_name /bin/bash

8. Use docker-compose now to manage docker installations

eg https://github.com/naga3/docker-lamp

9. In your dockerfile, When you pull from docker library, you are running its dockerfile first before running yours

eg FROM php:5.6-apache

Good resource:

kickstart docker lamp setup

git push origin feature refspec error

If you try to

git push -u origin feature/branch_name

and you get this error “error: src refspec feature/branch_name does not match any”, it means that your local branch are not named correctly. It should be named


as well, not just branch_name. Do a “git branch” to confirm yourself.

FTP in yosemite

we can use the in build ftp daemon

To load:

sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist

To unload:

sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist

Vagrant Authentication fails

Sometimes things go wrong during vagrant setup especially if have set it up already. You might get errors like “Authentication Failure” during “vagrant up” command. It is troublesome to get into the VM if there is no ssh key.

Type in

vagrant ssh-config

To see whats happening.

make sure u have ssh keys already.

then get into the vm with user “vagrant” and passwd “vagrant”

put id_rsa.pub into ~/.ssh/authorized_keys

you should be able to ssh into vagrant vm with “vagrant ssh” now.

Tips for working with dates in PHP

Converting from different date format can be challenging. All the php and mysql date functions can be confusing. Just store the date as yearmmdd format, eg 20160220 means year 2016, 02 month and 20 day. This format works well with strtotime function. As per unix timestamp, you can also use basic arithmetic to compare the dates in this format.

Asynchronous vs synchronous in javascript

you often see the terms asynchronous and synchronous in javascript. there is significant difference between the 2 and it affects the way you code. When executing something synchronously, you wait for it to finish before moving on. When executinge something asynchronously, you move on to the next task before it finishes.

google map geocoding is asynchronous for example, so you need to pass a callback method to execute upon completion of the request