Tuesday, June 1, 2010

Symfony Tips (part2)

1. Error 500
http://symfony-check.org/

throw new sfException('Testing the 500 error'); 

http://www.symfony-project.org/gentle-introduction/1_4/en/19-Mastering-Symfony-s-Configuration-Files#chapter_19_sub_default_modules_and_actions

symfony 1.2-
web/errors/error500.php

symfony 1.2+
config/error/error.html.php
config/error/unavilable.php


In application settings.yml
set check_lock to true

2. Session name

# ProjectName/apps/appName/config/factories.yml
  storage:
    class: MysqlSession
    param:
        session_name: xxxsession
        db_table: session
        database: uxsession


http://www.symfony-project.org/reference/1_4/en/07-Databases
symfony use databases.yml to determine the connection settings (host, database name, user, and password)

# ProjectName/config/database.yml

all:
 
xxxsession:
    class:          sfPropelDatabase
    param:
      dsn:          mysql://xxxxxxx


Problem:
Fatal error: Class 'sfPropelDatabase' not found in /root/workspace/ProjectName/cache/appName/dev/config/config_databases.yml.php on line 6

From doctrine to Prople
http://stackoverflow.com/questions/1835676/switch-symfony-1-4-from-doctrene-to-propel

#ProjectName/config/ProjectConfiguration.class.php

public function setup()
{
//    $this->enablePlugins('sfDoctrinePlugin');
      $this->enablePlugins('sfPropelPlugin');
}


Problem:
Fatal error: Declaration of MysqlSession::sessionWrite() must be compatible with that of sfDatabaseSessionStorage::sessionWrite() in /root/workspace/ProjectName/lib/symfony/MysqlSession.class.php on line 2


#ProjectName/lib/symfony/MysqlSession.class.php
public function sessionWrite($id, &$data) //reference parameter


Problem:
Unable to open PDO connection [wrapped: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)]



3. Incomplete Object

Fatal error: xxx_xxxActions::executeGroup() : The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition XXXXXXX of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /root/workspace/xxxx/actions/actions.class.php on line 40

Add the XXXXXXX object into the config.php

require_once('xxxxxx/service/xxxx/XXXXXXX.php');

4. Symfony cc
Different environment, index_dev.php works, index.php not.
Try to symfony10 cc, command not found;
Use ./symfony cc

No comments:

Post a Comment