Hear the symfonyWed, Jul 16, 2014
When I moved here to start going to university, I searched for interesting companies to work for. One of them stated on their website that they use the symfony2 PHP framework.” I have never done much in the web area, but have always been interested in getting started. Because I was totally in exam period I rather should have studied, but decided to give symfony a quick look.
Somfonys website is excellent. A lot of information, and very clearly presented. Nevertheless it took my some time to set it up, mainly because I never did it before nor played with PHP.
To get an overview I followed their guide The Big picture.
You should also now that I did all this on OSX.
First thing is to install symphony via composer, a PHP dependency management tool. For some reason it was already installed on my computer, but I don’t know if I played with PHP before and installed computer on the way or if it ships with OSX be default. I assume that I installed it myself and forgot about it though.
Installing composor isn’t difficult at all on OSX you can do it via homebrew:
brew update brew tap homebrew/homebrew-php brew tap homebrew/dupes brew tap homebrew/versions brew install php55-intl brew install homebrew/php/composer
And for other operating systems you can just follow their installation instructions.
Unfortunately installing symfony itself, was the first thing that didn’t work.
$: composer create-project symfony/framework-standard-edition myproject/ 2.5` Installing symfony/framework-standard-edition (v2.5.0) - Installing symfony/framework-standard-edition (v2.5.0) Loading from cache Created project in myproject/ Loading composer repositories with package information Installing dependencies (including require-dev) Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar/src/
Seems like something is running out of memory, but why? It isn’t that much after all. After some investigating it seemed like Composer was running out of memory when trying to build the dependency tree. And that I can configure how much memory it has at it’s disposal in the PHP config.
In /usr/local/etc/php/5.5/php.ini I looked for memory_limit and changed it’s value to -1 for unlimited. Since this is my private machine used for development this should be okay.
$ php -i | grep ini Configuration File (php.ini) Path => /etc $ php -i | grep Loaded Configuration Loaded Configuration File = (none)
Aha! PHP thought my ini is in
/etc/ when I really edited the one in
/usr/local/etc/php/5.5/php.ini. However when looking into the directory I saw that there was a template file, which I decided to edit instead.
$ cp /etc/php.ini.default /etc/php.ini $ su vim /etc/php.ini
Making the same change in this file and saving it I eliminated the error, but got a new one in return.
$ composer create-project symfony/framework-standard-edition myproject/ ~2.5 [Symfony\Component\Debug\Exception\ContextErrorException] Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Users/alguen/src/symfonytest/myproject/vendor/monolog/monolog/src/Monolog/Logger.php line 233
The message continued with several other errors, but one step at a time, right? When looking for timezone in my PHP.ini I found
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone =
So there was one more mistake to fix, the line was commented out.
Checking http://php.net/date.timezone for the correct syntax, I used:
date.timezone = "Europe/Berlin" ran the installation command again and: it worked!
After this the tutorial was a breeze, and gave me a nice overview of symfony. Being my first time engaging in web development stuff, I also enjoyed the chapter HTTP Fundamentals in their online symfony book.
Actually, let’s just work through that now too. What? Exams in two days? Oh well…
I know my priorities.