Showing posts with label symfony. Show all posts
Showing posts with label symfony. Show all posts

Thursday, February 10, 2011

Symfony Upgrade Issues

1. XXXPeer::doselectrs()
Fatal error: Call to undefined method XXXPeer::doselectrs() in /root/workspace/ProjectName/lib/model/XXXPeer.php on line 37
That method belongs to Propel 1.2, and you are using Propel 1.3, which was introduced into symfony in symfony version 1.2
http://www.propelorm.org/wiki/Documentation/1.3/Upgrading#NewPropelMethodSignatures

New Propel Method Signatures
Another change is related to PDO's lack of a ResultSet correlate. The generated Peer doSelectRS() method has been renamed doSelectStmt(). PDO does not have a ResultSet class, so the doSelectStmt() will return an executed statement.

Solved:
Change doSelectRS() to doSelectStmt()

2. PDOStatement::next()
Fatal error: Call to undefined method PDOStatement::next() /root/workspace/ProjectName/lib/model/XXXPeer.php on line 39
same link as above

Solved:
change

$rs = AuthorPeer::doSelectRS(new Criteria());
while($rs->next()) {
$a = new Author();
$a->hydrate($rs);
}


to

// example of how to manually hydrate objects
$stmt = AuthorPeer::doSelectStmt(new Criteria());
while($row = $stmt->fetch(PDO::FETCH_NUM)) {
$a = new Author();
$a->hydrate($row);
}


3. PDOStatement::getInt()
Fatal error: Call to undefined method PDOStatement::getInt() in /root/workspace/ProjectName/lib/model/XXXPeer.php on line 41

tried:
http://www.symfony-project.org/blog/2008/05/30/how-do-i-use-propel-1-3-in-symfony-1-1

$ cd /path/to/project/root/
$ svn co http://svn.symfony-project.com/plugins/sfPropelPlugin/branches/1.3/ plugins/sfPropelPlugin

no luck

4. stdClass::getName()
Fatal error: Call to undefined method stdClass::getName() in /root/workspace/PHPLIB_ResourceServiceAdapter/ResourceService/service/search/RES_ResourceConditionManager.php on line 54

5. Enable the Compatibility with the Version 1.0
/admerch/apps/cm/config/settings.yml

.settings:
compat_10: true

Wednesday, February 9, 2011

Symfony Upgrade from 1.0 to 1.3

The upgrade from symfony 1.0 projects to 1.2 requires that projects first be upgraded to version 1.1, then 1.2 and finally 1.4. Before beginning the process ensure that the multiple version configuration has been completed. The following instructions will only serve as the base for the upgrade. For full details of the upgrade process and the changes there in visit the following pages:

http://www.symfony-project.org/installation/1_1/upgrade
http://www.symfony-project.org/installation/1_2/upgrade
http://www.symfony-project.org/tutorial/1_4/en/upgrade

1. Change directory into the root of project to upgrade
2. Copy the symfony skeleton file from the 1.1 symfony library
cp /opt/symfony/symfony11/lib/task/generator/skeleton/project/symfony

3. Copy the project skeleton file from the 1.1 symfony library
cp /opt/symfony/symfony11/lib/task/generator/skeleton/project/config/ProjectConfiguration.class.php config/

4. Edit the config/ProjectConfiguration.class.php file and ensure that the require_once points to the valid path and that the configuration and includes from the older config.php are set.

ini_set(‘include_path’, ‘/usr/lib/phplib/libs:’ . ini_get(‘include_path’));
define(‘__DEBUG__’, 0);
define(‘CONFIGPATH’, dirname(__FILE__) . ‘/config.xml’);
define(‘CONFIGTYPE’, ‘XML’);
require_once(‘/opt/symfony/symfony11/lib/autoload/sfCoreAutoload.class.php’);


5. Run the upgrade script
./symfony project:upgrade1.1

6. Once the upgrade script has completed remove any depreciated configuration files (logging, i8n, etc)
read the output, migrate the config file then remove files

7. All of the batch scripts in the project will have to be updated have the following header information in place of the existing.

require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
sfContext::createInstance($configuration);
$databaseManager = new sfDatabaseManager($configuration);
$databaseManager->loadConfiguration();


8. Access the application and ensure that it is in a basic working state (it easier to do this after each upgrade than waiting until the end)
1) Flash attributes
change
$sf_flash->has('good')
to
$sf_user->hasFlash('good')

change
$this->setFlash('error_msg', 'Sorry');
to
$this->getUser()->setFlash('error_msg', 'Sorry');

change
$sf_flash->get('error_msg')
to
$sf_user->getFlash('error_msg');

Problem 1)
[sfException]
Call to undefined method WebController::getContext

Solved: Turn off customized webcontroller  for now
Project/apps/app/config/factories.yml

all:
# controller:
# class: WebController


9. Edit the config/ProjectConfiguration.class.php file updating the symfony include to point to the 1.2 version.

require_once(‘/opt/symfony/symfony12/lib/autoload/sfCoreAutoload.class.php’);


10. Run the symfony 1.2 upgrade
symfony12 project:upgrade1.2

11. Upgrade the databases.yml into the new format
Old Format

all:
propel:
class: sfPropelDatabase
param:
dsn: mysql://username:password@localhost/example

New Format

dev:
propel:
param:
classname: DebugPDO

test:
propel:
param:
classname: DebugPDO

all:
propel:
class: sfPropelDatabase
param:
dsn: mysql:dbname=example;host=localhost
username: username
password: password
encoding: utf8
persistent: true
pooling: true
classname: PropelPDO


12. Rebuild the propel module by running the following

symfony12 propel:build-model


Problem 2)
build-propel.xml:479:1: Table 'xxxxx' does not have a primary key defined. Propel requires all tables to have a primary key.
build-propel.xml:465:22: Execution of the target buildfile failed. Aborting.

Solved: add primaryKey="true"
Project/config/admerch.schema.xml

13. If your application makes use database sessions update your factories.ymlas such
storage:
class: sfPDOSessionStorage
param:
session_name: session
db_table: session
db_id_col: sess_id
db_data_col: sess_data
db_time_col: sess_time
database: example

14. It is strongly recommended to disable any specialized classes, other than the user object, in the factories.yml file.

Problem 3)
500 | Internal Server Error | sfDatabaseException
Database "example" does not exist.
1.at () in SF_SYMFONY_LIB_DIR/database/sfDatabaseManager.class.php line 109 ...
2.at sfDatabaseManager->getDatabase('inpulse_ad')
in SF_ROOT_DIR/cache/cm/dev/config/config_factories.yml.php line 111 ...
3. at require('/root/workspace/admerch/cache/cm/dev/config/config_factories.yml.php')
in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 149 ...
4. at sfContext->loadFactories()
in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 76 ...
5.at sfContext->initialize(object('cmConfiguration'))
in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 59 ...

Solved.
/admerch/apps/cm/config/factories.yml
replace

storage:
class: sfPDOSessionStorage
param:
session_name: session
db_table: session
db_id_col: sess_id
db_data_col: sess_data
db_time_col: sess_time
database: example

use default session

storage:
class: sfSessionStorage
param:
session_name: symfony


15. The underlying propel connection has changed from creole to PDO. Any peer classes that directly hydrate data objects will have to be updated to use the PDO API. Please visit: http://www.symfony-project.org/installation/1_2/upgrade for the complete information.

Locate /admerch/config/propel.ini
change

propel.database = mysql
propel.database.createUrl = mysql://username:password@localhost/
propel.database.url = mysql://username:password@localhost/example

Replace with the following

propel.database = mysql
propel.database.driver = mysql
propel.database.url = mysql:dbname=example;host=localhost
propel.database.user = username
propel.database.password = password
propel.database.encoding = utf8


need to rebuild the object model:

symfony12 propel:build-model


Problem 4)
Error importing addon/propel/builder/SfPeerBuilder.php
Execution of target "om" failed for the following reason: /opt/symfony/symfony12/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml:465:22: Execution of the target buildfile failed. Aborting.
[phing] /opt/symfony/symfony12/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml:465:22: Execution of the target buildfile failed. Aborting.


Solved
http://blog.vacs.fr/index.php?post/2009/02/08/Symfony-cryptic-error%3A-Error-importing-plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php

http://oldforum.symfony-project.org/index.php/m/59416/
missing addon/propel/builder/SfPeerBuilder.php file

propel.builder.peer.class = addon.propel.builder.SfPeerBuilder
propel.builder.object.class = addon.propel.builder.SfObjectBuilder



create a new symfony12 project

propel.builder.peer.class = plugins.sfPropelPlugin.lib.builder.SfPeerBuilder
propel.builder.object.class = plugins.sfPropelPlugin.lib.builder.SfObjectBuilder
propel.builder.objectstub.class = plugins.sfPropelPlugin.lib.builder.SfExtensionObjectBuilder
propel.builder.peerstub.class = plugins.sfPropelPlugin.lib.builder.SfExtensionPeerBuilder
propel.builder.objectmultiextend.class = plugins.sfPropelPlugin.lib.builder.SfMultiExtendObjectBuilder
propel.builder.mapbuilder.class = plugins.sfPropelPlugin.lib.builder.SfMapBuilderBuilder


Problem 5)
500 | Internal Server Error | PropelException
Unable to find adapter for datasource [example].

Solved.
ProjectName/config/example.schema.xml

database name="example"

ProjectName/config/database.yml

all:
example:
class: sfPropelDatabase
param:
dsn: mysql:dbname=example;host=hostname
username: username
password: password
encoding: utf8
persistent: true
pooling: true
classname: PropelPDO



16. Edit the config/ProjectConfiguration.class.php file updating the symfony include to point to the 1.3 version.

require_once(‘/opt/symfony/symfony13/lib/autoload/sfCoreAutoload.class.php’);


17. Before switching your project to 1.3 run the following in your project directory
validate project

symfony13 project:validate


http://www.symfony-project.org/tutorial/1_4/en/deprecated
This will identify any areas of your project that need to be modified due to removal of old features. As a note it’s pretty good at finding things but a full test of the application will be needed to validate the upgrade.

18. Upgrading from 1.2 to 1.3 is as simple as executing the following in your project directory

symfony13 project:upgrade1.3
symfony13 propel:build --all-classes


Problem 6)
run symfony13 propel:build --all-classes
Cannot fetch TableMap for undefined table: location

19. Before switching your project to 1.4 run the following in your project directory

symfony14 project:validate

This will identify any areas of your project that need to be modified due to removal of old features. As a note it’s pretty good at finding things but a full test of the application will be needed to validate the upgrade.

20.Once the project successfully validates under 1.4 run the following to complete the upgrade.

symfony14 project:upgrade1.4

Symfony: Import Project

1. Can't find PHPLIB_***
/UX_inPulseAd/config/config.php

Solved:

ini_set('include_path', '/root/workspace/phplib:' . ini_get('include_path'));


2. [sfCacheException]
Unable to read cache file "/root/workspace/ProjectName/cache/appName/dev/config/config_config_handlers.yml.php"

Warning: copy(/root/workspace/UX_inPulseAd/cache/cm/dev/config/config_autoload.yml.php) [function.copy]: failed to open stream: Permission denied in /opt/symfony/symfony10/lib/cache/sfFileCache.class.php on line 553

Warning: chmod() [function.chmod]: No such file or directory in /opt/symfony/symfony10/lib/cache/sfFileCache.class.php on line 559

Fatal error: Class 'sfDatabaseConfigHandler' not found in /root/workspace/UX_inPulseAd/cache/cm/dev/config/config_config_handlers.yml.php on line 25

Solved:
The permissions of the project files and directories can be broken if you use a checkout from an SVN repository. The project:permissions task fixes directory permissions, to change the log/ and cache/ permissions to 0777, for example (these directories need to be writable for the framework to work correctly).

http://www.symfony-project.org/book/1_2/16-Application-Management-Tools


symfony12 project:permissions


doesn't use symfony10 project:permissions
[pakeException]
Task "project:permissions" is not defined.

or use
chmod -R 777 cache/
3. Memcache
Notice: Memcache::connect() [memcache.connect]: Server localhost (tcp 11211, udp 0) failed with: Connection refused (111) in /root/workspace/PHPLIB_CommonAdapter/CommonAdapter/support/COM_MemcacheCache.php on line 30

comments out in config.xml
localhost
11211

4. CVS out of sync
Refresh the directory in eclipse

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

Thursday, May 27, 2010

Symfony: Mailer

In action

$message = $this->getMailer()->compose(
    array('your@email.com'=>'Your Name'),
    'otheremail@email.com',
    'Subject',
    'Body'
);
$this->getMailer()->send($message);


factories.yml

dev:
  mailer:
     class: sfMailer
     param:
       logging:           %SF_LOGGING_ENABLED%
       charset:           %SF_CHARSET%
       delivery_strategy: realtime
       transport:
         class: Swift_SmtpTransport
         param:
           host:       localhost
           port:       25
           encryption: ~
           username:   ~
           password:   ~

Wednesday, May 19, 2010

Symfony Tips

1. Add Timer (symfony 1.0)

/**** init timer *****/
$timer = sfTimerManager::getTimer('myTimer');
/**********/


/**** display timer *****/
$timer->addTime();
$elapsedTime = $timer->getElapsedTime();
echo $elapsedTime;
die();
/**********/


2. Unit Test (symfony 1.4)
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/08
Create test.php file under ProjectName/test/unit/test

// test/unit/JobeetTest.php
require_once dirname(__FILE__).'/../bootstrap/unit.php';

$t = new lime_test(1);
$t->pass('This test always passes.');


To launch the test
$ php test/unit/test.php

Sample

require_once dirname(__FILE__).'/../bootstrap/unit.php';
$t = new lime_test(6); // display 1..6

$t->comment('::slugify()'); // display #::slugify()
$t->is(Jobeet::slugify('Sensio'), 'sensio', '::slugify() converts all characters to lower case'); // display ok 1 - ::slugify() converts all ...


3. User Flash (symfony 1.4)
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/13
A flash is an ephemeral message stored in the user session that will be automatically deleted after the very next request. It is very useful when you need to display a message to the user after a redirect.

setFlash(): The first argument is the identifier of the flash and the second one is the message to display. You can define whatever flashes you want, but notice and error are two of the more common ones.
// apps/frontend/modules/job/actions/actions.class.php
public function executeExtend(sfWebRequest $request)
{
    $request->checkCSRFProtection();

    $job = $this->getRoute()->getObject();
    $this->forward404Unless($job->extend());

    $this->getUser()->setFlash('notice', sprintf('Your job validity has been extended until %s.', $job->getDateTimeObject('expires_at')->format('m/d/Y')));

    $this->redirect($this->generateUrl('job_show_user', $job));
}

Include the flash message in the templates
// apps/frontend/templates/layout.php
<?php if ($sf_user->hasFlash('notice')): ?>
  <div class="flash_notice"><?php echo $sf_user->getFlash('notice') ?></div>
<?php endif ?>
 
<?php if ($sf_user->hasFlash('error')): ?>
  <div class="flash_error"><?php echo $sf_user->getFlash('error') ?></div>
<?php endif ?>


4. User Attribute (symfony 1.4)
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/13
getAttribute(), setAttribute()

// apps/frontend/modules/job/actions/actions.class.php
class jobActions extends sfActions
{
    public function executeShow(sfWebRequest $request)
    {
    $this->job = $this->getRoute()->getObject();

    // fetch jobs already stored in the job history
    $jobs = $this->getUser()->getAttribute('job_history', array());

    // add the current job at the beginning of the array
    array_unshift($jobs, $this->job->getId());

    // store the new job history back into the session
    $this->getUser()->setAttribute('job_history', $jobs);
    }
}

myUser class
The myUser class overrides the default symfony base sfUser class with application specific behaviors

// apps/frontend/modules/job/actions/actions.class.php
class jobActions extends sfActions
{
    public function executeShow(sfWebRequest $request)
    {
    $this->job = $this->getRoute()->getObject();

    $this->getUser()->addJobToHistory($this->job);
    }
}
// apps/frontend/lib/myUser.class.php
class myUser extends sfBasicSecurityUser
{
    public function addJobToHistory(JobeetJob $job)
    {
    $ids = $this->getAttribute('job_history', array());

    if (!in_array($job->getId(), $ids))
    {
        array_unshift($ids, $job->getId());
        $this->setAttribute('job_history', array_slice($ids, 0, 3));
    }
    }
}

remove attribute
User's attributes are managed by an object of class sfParameterHolder. The getAttribute() and setAttribute() methods are proxy methods for getParameterHolder()->get() and getParameterHolder()->set().

// apps/frontend/lib/myUser.class.php
class myUser extends sfBasicSecurityUser
{
    public function resetJobHistory()
    {
        $this->getAttributeHolder()->remove('job_history');
    }
}



5. i18n and l10n (symfony 1.4)
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/19
User Culture
The language French is ‘fr’, English is ‘en’; the country Canada is ‘CA’, United States is ‘US’; the culture for a user speaking French from Canada is ‘fr_CA’
setCulture()and getCulture()

// in an action
$this->getUser()->setCulture('fr_BE');
echo $this->getUser()->getCulture();

The preferred user culture can be configured in the settings.yml configuration file

#apps/frontend/config/settings.yml
all:
    .settings:
       default_culture: en_CA

Internationalization
set i18n setting to true in settings.yml

# apps/frontend/config/settings.yml
all:
   .settings:
       charset: utf-8
       i18n: true

The I18N helper group is not loaded by default, you need to either manually add itin each template with use_helper(‘I18N’) or load it globally by adding to the standard_helpers setting

# apps/frontend/config/settings.yml
all:
   .settings:
      standard_helpers: [Partial, Cache, I18N]

Sample template of how to use the __() helper

    // apps/frontend/templates/layout.php

      <a href=""><?php echo __('About Jobeet') ?></a>

      <?php echo link_to(__('Full feed'), 'job', array('sf_format' => 'atom')) ?>

    Create catalogue using i18n:extract

    $ php symfony i18n:extract frontend fr --auto-save

    Each translation is managed by a trans-unit tag which has a unique id attribute. A lot of tools exist to ease the translation process. (check out Open Language Tools https://open-language-tools.dev.java.net/)

    <!-- apps/frontend/i18n/fr/messages.xml -->

    <xliff version="1.0">
      <file source-language="EN" target-language="fr" datatype="plaintext"
          original="messages" date="2008-12-14T12:11:22Z"
          product-name="messages">
        <header/>
        <body>
          <trans-unit id="1">
            <source>About Jobeet</source>
            <target>A propos de Jobeet</target>
          </trans-unit>
          <trans-unit id="2">
            <source>Feed</source>
            <target>Fil RSS</target>
          </trans-unit>
        </body>
      </file>
    </xliff>

    How to use format_date
    sfDateFormat::getPattern()
    http://fellipeeduardo.com/blog/symfony-helper-format_date-how-to-use/en/

    6. autoload.yml (symfony 1.4)
    http://www.symfony-project.org/reference/1_4/en/14-Other-Configuration-Files
    The autoload.yml configuration determines which directories need to be autoloaded by symfony

    7. Authentication (symfony 1.4)
    entire application require the user to be authenticated

    # apps/backend/config/security.yml
    default:
       is_secure: true

    when an un-authenticated user tries to access a secured action, symfony forwards the request to the login action

    # apps/backend/config/setting.yml
    all:

      .actions:
         login_module: default
         login_action: login


    By default, the myUser class extends sfBasicSecurityUser, and not sfUser. sfBasicSecurityUser provides additional methods to manage user authentication and authorization.

    To manage user authentication, use the isAuthenticated() and setAuthenticated() methods:

    if (!$this->getUser()->isAuthenticated())
    {
        $this->getUser()->setAuthenticated(true);
    }


    8. Basic File Structure (1.2)
    http://www.symfony-project.org/book/1_2/19-Mastering-Symfony-s-Configuration-Files

    sf_root_dir # myproject/
    sf_apps_dir # apps/
    sf_app_dir # frontend/
    sf_app_config_dir # config/
    sf_app_i18n_dir # i18n/
    sf_app_lib_dir # lib/
    sf_app_module_dir # modules/
    sf_app_template_dir # templates/
    sf_cache_dir # cache/
    sf_app_base_cache_dir # frontend/
    sf_app_cache_dir # prod/
    sf_template_cache_dir # templates/
    sf_i18n_cache_dir # i18n/
    sf_config_cache_dir # config/
    sf_test_cache_dir # test/
    sf_module_cache_dir # modules/
    sf_config_dir # config/
    sf_data_dir # data/
    sf_doc_dir # doc/
    sf_lib_dir # lib/
    sf_log_dir # log/
    sf_test_dir # test/
    sf_plugins_dir # plugins/
    sf_web_dir # web/
    sf_upload_dir # uploads/


    9. Use Helper in Action
    http://snippets.symfony-project.org/snippet/69
    In PrjectConfiguration file

    # ProjectName/config/ProjectConfiguration.class.php
    include_once('/opt/symfony/symfony14/lib/helper/DateHelper.php');

    In Action
    format_date(time(), 'D', 'fr');

    Format
    http://trac.symfony-project.org/wiki/formatDateHowTo

    Monday, May 10, 2010

    Symfony 1.4: Create New Project

    1. Create project directory under ~/workspace/
    [root/workspace]# mkdir ProjectName

    2. Create project
    [root/workspace/ProjectName]# symfony14 generate:project ProjectName

    in Eclipse
    File > New > PHP Project
    Project name: ProjectName

    3. Create application
    [root/workspace/ProjectName]# symfony14 generate:app appName

    4. Configuration
    [root/workspace/ProjectName]# chmod 777 cache/ log/

    create symfony softlink
    [root/workspace/ProjectName/web]# ln -s /opt/symfony/symfony14/data/web/sf

    create softlink
    [root]# cd /var/www/html
    [root/var/www/html]# ln -s ~/workspace/ProjectName

    under workspace/phplib
    [root/workspace/phplib]# ln -s ~/workspace/PHPLIB_***Adapter/***Service ***Service

    5. Create module
    under project directory ProjectName
    [root/workspace/ProjectName]# symfony14 generate:module appsName newModuleName

    6. Set routing
    /projectName/apps/appName/config/routing.yml
    homepage:
    url: /
    param: { module: public, action: index }


    7. Set view
    /projectName/apps/appName/config/view.yml

    default:
        http_metas:
           content-type: text/html
        metas:
           title:  Project Name
           robots: index, follow
           description: Project Description
           keywords: xxxx, xxxxx
           language: en
        stylesheets: [main]
        javascripts: []
        has_layout: on
        layout: layout



    customize the view for module

    # apps/frontend/modules/job/config/view.yml
    default:
    stylesheets: [public.css]

    resetSuccess:
    stylesheets: [main.css]


    8. Turn on/off debug toolbar
    Web Debug Toolbar Activation, in myapp/config/settings.yml

    dev:
        .settings:
           web_debug: true


    9. frontend_dev.php IP address check
    /projectName/web/frontend_dev.php

    // this check prevents access to debug front controllers that are deployed by accident to production servers.
    // feel free to remove this, extend it or make something more sophisticated.
    if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
    {
    die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
    }


    Error in Linux, but not on other machine
    Warning: session_start() [function.session-start]: Function spl_autoload_call() hasn't defined the class it was called for in /opt/symfony/symfony14/lib/storage/sfSessionStorage.class.php on line 93

    Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in /opt/symfony/symfony14/lib/yaml/sfYamlInline.php on line 105

    Tried symfony14 cc, still have the error
    Tried symfony14 clear-cache, red box - Task "clear-cache" is not defined
    Closed browser without saving, worked (should just clear session/cookie);
    symfony clear-cache is changed to symfony cache:clear

    10. Forms
    1) FormHelper was removed from symfony 1.4, so input_tag(), checkbox_tag() and etc not working.
    http://www.symfony-project.org/forms/1_4/en/

    2) Notice: Undefined variable: sf_flash
    Use $sf_user->hasFlash()

    11. Auth
    Load AuthenticationService

    # ProjectName/config/ProjectConfiguration.class.php
    require_once('AuthenticationService/service/ASA_AuthSession.php');

    Add Auth.class.php

    # ProjectName/lib/symfony/Auth.class.php
    public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $options = array()) { 

    }
    public function setAuthenticated($authenticated) {
        #throw new Exception('here');
        #sfContext::getLogger()->log('CSC_User::setAuthenticated is not implemented.');
    }

    public function addCredential($credential) {
        #sfContext::getLogger()->log('CSC_User::addCredential is not implemented.');
    }

    configure factories.yml

    # ProjectName/apps/appName/config/factories.yml
    all:
       user:
        class: Auth


    12. Login
    Create new component instance in CSC

    13. After move project / import other's project

    Warning: copy(/home/eshare/projects/sfproject2/cache/frontend/prod/config/config_config_handlers.yml.php) [function.copy]: failed to open stream: [B]Permission denied in /home/eshare/projects/sfproject2/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 359[/B]

    Warning: chmod() [function.chmod]: No such file or directory in /home/eshare/projects/sfproject2/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 365

    Warning: require(/home/eshare/projects/sfproject2/cache/frontend/prod/config/config_config_handlers.yml.php) [function.require]: failed to open stream: No such file or directory in /home/eshare/projects/sfproject2/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 279

    Fatal error: require() [function.require]: Failed opening required '/home/eshare/projects/sfproject2/cache/frontend/prod/config/config_config_handlers.yml.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/eshare/projects/sfproject2/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 279


    clear the cache completely. (remove the folders inside cache)
    Also run symfony project:permissions

    Friday, May 7, 2010

    Symfony: Multiple Version in same environment

    Your Complete Guide to Running Multiple
    Symfony Versions on the Same Environment
    http://symfonynerds.com/blog/?p=123

    Step 1 Uninstall any existing symfony installations
    [root]# pear uninstall symfony/symfony
    uninstall ok: channel://pear.symfony-project.com/symfony-1.0.20

    Step 2 Create a /opt/symfony directory
    Install symfony in /usr/share/php/symfony
    [root]# cd /opt/
    [root/opt]# mkdir symfony

    Step 3 Within the created /opt/symfony directory checkout the symfony 1.0 through 1.4 versions using SVN
    [root/opt]# cd symfony/
    [root/opt/symfony]# svn co http://svn.symfony-project.com/branches/1.0 symfony10
    ...
    [root/opt/symfony]# svn co http://svn.symfony-project.com/branches/1.1 symfony11
    ...
    [root/opt/symfony]# svn co http://svn.symfony-project.com/branches/1.2 symfony12
    ...
    [root/opt/symfony]# svn co http://svn.symfony-project.com/branches/1.3 symfony13
    ...
    [root/opt/symfony]# svn co http://svn.symfony-project.com/branches/1.4 symfony14
    ...
     


    Step 4 Create symbolic links to the symfony commands in the bin directory
    ln -s /opt/symfony/symfony10/data/bin/symfony /usr/bin/symfony10
    ln -s /opt/symfony/symfony11/data/bin/symfony /usr/bin/symfony11
    ln -s /opt/symfony/symfony12/data/bin/symfony /usr/bin/symfony12
    ln -s /opt/symfony/symfony12/data/bin/symfony /usr/bin/symfony13
    ln -s /opt/symfony/symfony12/data/bin/symfony /usr/bin/symfony14

    To test the links
    [root]# symfony10 -V
    symfony versoin 1.0.22-LAST
    [root]# symfony11 -V
    symfony versoin 1.1.10-DEV (/opt/symfony/symfony11/lib)

    Step 5 Update any existing symfony 1.0 projects to use the following include directories
    project/config/config.php
    $sf_symfony_lib_dir  = '/opt/symfony/symfony10/lib';
    $sf_symfony_data_dir = '/opt/symfony/symfony10/data';


    Step 6 New symfony 1.4 projects can use the following to create the projects
    symfony14 generate:project ProjectName