Screen Shot 2014-11-18 at 1.55.52 PM This is the last chapter of the Getting Started Tutorial. It was very helpful and informative.

There’s not a lot of code to execute or test out here, but it does give a good overview of what each directory in the downloaded file structure is used for. That’s helpful. I like the changes I see from version 1.x. I also like the idea of bundles and inheritance.

I’m used to the YAML files and the cache from Symfony 1.0, so that’s not really new. The app/console is vaguely familiar, but different.

I was having a problem all through the tutorial with the app/console. Since I was using MAMP for my server environment, I hadn’t really needed it, but after reading this chapter, I decided I better figure out why it’s not working.

When I tried to run app/console, I was getting this error:

[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 'UT  
  C' for now, but please set date.timezone to select your timezone. in /Users/cindy/sites/myproject/vendor/monolog/mono  
  log/src/Monolog/Logger.php line 233 

Then it would just quit. Never executed any of my command line commands. Obviously, I need to set the default time zone, but wasn’t exactly sure where or how to do that.

I found that there are several different ways to set the default time zone. You can set it in php.ini or .htaccess. Apparently my Mac’s php.ini doesn’t set the default time zone. I could set it there or in .htaccess, but, I chose to set it in the Symfony code so that it will move with the code if I change servers or access the code in different ways.

To do that I opened up app/AppKernal.php and added this function inside the class:

class AppKernel extends Kernel
{
	public function init()
    {
        date_default_timezone_set( 'America/Chicago' );
        parent::init();
    }
    
    public function registerBundles()
.
.
.

Works great and now, even the homepage works which I can’t get to work in MAMP without using app_dev.php! I’m sure I’ll figure out why as I work through the book which I’m ready to dive into!

Edited: 12/12/2014
I’m still getting some timezone errors on the symfony command line, so I decided to fix this at the php.ini level. php.ini on my Mac is located here: /private/etc

If it’s not there, you should find this at least: php.ini.default

Copy this file to php.ini like this:

sudo cp /private/etc/php.ini.default /private/etc/php.ini

then change this line:

date.timezone = America/Chicago

I’m not sure if this is working for everything yet, but so far, so good.

1 thought on “Symfony Getting Started Tutorial – The Architecture”

  1. Pingback: The symfony Getting Started Big Picture Tutorial - Cullen Web Services

Leave a Comment

Your email address will not be published. Required fields are marked *