airplane in he runway

Deploying Symfony on Production Server

Time to ship your symfony app to production? Here are some flight checks. Lets assume your symfony app is in folder symfony-app

1. Don’t put Symfony app in the public accessible folder on your server

If your servers public facing folder is, say, /var/www/html, then don’t put the whole symfony folder there.

Choose another deeper and non-public facing folder. Let say /apps/symfony-app. I will list how you would put the public facing folders later.
For this to happen run this command on your server

mkdir /apps

2. Pushing your code to production server

You can use FTP client like filezilla or cyberduck and put your code in /apps
If you are using git, then you can clone your app like this

cd /apps
git clone https://username@bitbucket.org/username/symfony-app.git symfony-app

Continue reading Deploying Symfony on Production Server

test

Run single phpunit test

Well, we all love php unit tests :). There are times we would like to run one/single test from test suite that has failed so that we can fix or look at it thoroughly. PHPUnit has a way to do it.
The problem, when you are your php unit suite as

phpunit -c /testFolder..

All you php tests would run.
The solution for this is:
Let’s assume you have this particular php unit test in one of your test files

public function testPhpIsAwesomeOrNot(){
}

All you have to do is to add the <b>group annotation</b> above the function of your php unit test

/**
 * @group awesome
 */
public function testPhpIsAwesomeOrNot(){}

and run your PHPUnit single test wiht –group annotation

phpunit -c /testfolder --group awesome

The above would run single PHPUnit test from the test suite.

Screen Shot 2016-04-10 at 9.21.59 PM

Upgrade mysql version from 5.5 to 5.6

Upgrade mysql version

This would probably make sense on Amazon EC2 instance where it comes by default with
mysql 5.5, as of this writing, and you want to upgrade mysql to the next version.

In this example I have used version 5.5 for the upgrade mysql example. But, technically the methodology would work for other versions as well unless mysql drastically changes folder locations.

How to upgrade mysql from 5.5 to 5.6

First go ahead and move the mysql 5.5 to new folder

sudo mv /var/lib/mysql /var/lib/mysql55

Then grab the tar from mysql download page [Here]

Once you download the tar file containing the new mysql version do the following commands on your terminal.

sudo tar -xvf yourDownloadedTar.tar
sudo rpm -ivh MySQL-shared-5.6.17-1.el6.x86_64.rpm
sudo rpm -ivh MySQL-client-5.6.17-1.el6.x86_64.rpm
sudo rpm -ivh MySQL-server-5.6.17-1.el6.x86_64.rpm

This would upgrade your current mysql version to mysql 5.6 or which ever is the new mysql version.

Then restart mysql for the change to take effect.

Screen Shot 2016-04-10 at 7.49.57 PM

composer install-update killed on vagrant machine

These are also other stuffs going on:
composer update or composer install takes forever and the command line responds as killed

Specially this might happen on ordinary symfony application.Screen Shot 2016-04-10 at 8.16.40 PM

This is mostly, very very likely, related to memory issue.

Solution 1: perform your composer update or install on the host machine if possible.

This might not be possible in some scenarios if there are dependencies that rely on installed packages.

But, if that is not the problem, have on the host and the files would be sync’d anyway.Screen Shot 2016-04-10 at 8.07.07 PM

Solution 2: increase the memory on the provision file you have. I am using puphpet so, for that all you would have to do would be

cd /path/to/puphpet/
vim comfig.yml

then search for memory which by default be 512 and increase it at least to 1024 or better 2048 and that should solve the problem

Tip

To see the how much memory you have on your vagrant machine, ssh into your machine and

vagrant ssh
free -h

the free command would tell you how much memory you have and how is used.

Screen Shot 2016-04-10 at 7.49.57 PM

install composer and make it globally accessible

Unless you have been living under rocks, you have heard about composer already. It is a dependency manager and more than that actually. If your PHP app is using a lot of dependencies, then it is time to consult composer.

Here I will put some notes on how to install it and make it available globally so that you can use it from any directory.

First thing first, go and grab the phar file from composer download page

It would be a single phar file and u can use that as it is:

composer.phar install

Of course you would need the composer.json file for the above to work where you would list the dependencies.

But, this would require you to call the phar from where you downloaded and that might not be handy

cd /to/composer/phar/file
sudo mv composer.phar /usr/local/bin/composer

Now, you can call composer from any directory and rock from there
get more @ get composer
That is how you install composer on linux/mac computer and make it globally accessible with in