Saturday, August 31, 2013

Set up Composer (PHP dependency manager) on OSX

Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.

Here is how to install it on OSX.

1. Go to the Symfony/, which is a directory where we will put the composer.phar:
$ cd ../Symfony
2. Download the composer.phar:
$ curl -s http://getcomposer.org/installer | php
3. Generates composer.phar (a PHP executable). Make sure it works fine:
$ php composer.phar

Symfony2: Creating Database

Here is a summary how to create a Database in symfony2 using CLI.
There are 3 roughly steps to create a database.

Create a class with annotation, or whatever format that you want.

Create database- which is set in the parameter.yml:
$ php app/console doctrine:database:create
Create table following the annotation: 
$ php app/console doctrine:schema:create 

Friday, August 30, 2013

Symfony2: Warning: date_default_timezone_get()

This is one way to solve the Waning: date_default_timezone_get(). The problem occurs when you try php app/console doctrine:schema:create command in the terminal and then it shows up the warning:
Warning: date_default_timezone_get()
This can be solved by changing the Php path point to MAMP.
If you are using the MAMP in OSX,  you currently have at least 2 installed PHP- OSX and MAMP.
Here is the commands to change PHP's path to MAMP, open your terminal and type the following commands:
$ sudo mv /usr/bin/php /usr/bin/php-bak
sudo ln -s /Applications/MAMP/bin/php/php5.x.x/bin/php /usr/bin/php
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/bin/mysql

Lastly, you must add  date.timezone = "Europe/Berlin" to a php.ini which is stored in /Applications/MAMP/bin/php/php5.x.x/conf

That's it!

NOTE: 
* Don't forget to change php5.x.x to map your php version.
* Change the date.timezone to suit your timezone, for example, "Europe/Berlin", "Asia/Bangkok".