setAuthenticated in symfony for frontend and backend

The problem:

i had two applications 1) frontend and 2) backend.

but when i login into backend i was automatically login into the frontend application.

The Solution:

the solution is simple you have to define the session name for both the application or atleast one. so that the sessions for both of them differ from each other.

you can define the session name in the “\apps\backend\config\factories.yml” file

here

cli:
controller:
class: sfConsoleController
request:
class: sfConsoleRequest
response:
class: sfConsoleResponse

test:
storage:
class: sfSessionTestStorage

all:
#  controller:
#    class: sfFrontWebController
#
#  request:
#    class: sfWebRequest
#
#  response:
#    class: sfWebResponse
#
#  user:
#    class: myUser
#
storage:
class: sfSessionStorage
param:
session_name: symfonyBack
#
#  view_cache:
#    class: sfFileCache
#    param:
#      automaticCleaningFactor: 0
#      cacheDir:                %SF_TEMPLATE_CACHE_DIR%

i have given a name for the backend application (symfonyBack).

database connection in symfony 1.0

There are two files that needs to be configure database connection in symfony 1.0:

Both the below files as found in <project>\config\         directory(folder)

1) database.yml:

all:
propel:
class:      sfPropelDatabase
param:
phptype:  mysql
hostspec: localhost
database: symfonycms
username: root
password:
#port: 80
encoding: utf8 # Default charset for table creation
#persistent: true # Use persistent connections

or as a short hand for the above

all:
propel:
class:      sfPropelDatabase
param:
phptype:  mysql
dsn: mysql://root:password@localhost/databas
#port: 80
encoding: utf8 # Default charset for table creation
#persistent: true # Use persistent connections

2)propel.ini

propel.targetPackage       = lib.model
propel.packageObjectModel  = true
propel.project             = symfonycms
propel.database            = mysql
propel.database.createUrl  = mysql://localhost/
propel.database.url        = mysql://root:@localhost/symfonycms

propel.addGenericAccessors = true
propel.addGenericMutators  = true
propel.addTimeStamp        = false

propel.schema.validate     = false

; directories
propel.home                    = .
propel.output.dir              = /var/www/production/sfweb/www/cache/symfony-for-release/1.0.20/sf_sandbox
propel.schema.dir              = ${propel.output.dir}/config
propel.conf.dir                = ${propel.output.dir}/config
propel.phpconf.dir             = ${propel.output.dir}/config
propel.sql.dir                 = ${propel.output.dir}/data/sql
propel.runtime.conf.file       = runtime-conf.xml
propel.php.dir                 = ${propel.output.dir}
propel.default.schema.basename = schema
propel.datadump.mapper.from    = *schema.xml
propel.datadump.mapper.to      = *data.xml

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

propel.builder.objectstub.class        = addon.propel.builder.SfExtensionObjectBuilder
propel.builder.peerstub.class          = addon.propel.builder.SfExtensionPeerBuilder
propel.builder.objectmultiextend.class = addon.propel.builder.SfMultiExtendObjectBuilder
propel.builder.mapbuilder.class        = addon.propel.builder.SfMapBuilderBuilder
propel.builder.interface.class         = propel.engine.builder.om.php5.PHP5InterfaceBuilder
propel.builder.node.class              = propel.engine.builder.om.php5.PHP5NodeBuilder
propel.builder.nodepeer.class          = propel.engine.builder.om.php5.PHP5NodePeerBuilder
propel.builder.nodestub.class          = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder
propel.builder.nodepeerstub.class      = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder

propel.builder.addIncludes = false
propel.builder.addComments = false

propel.builder.addBehaviors = false

Fatal error: Unsupported operand types in lib\symfomy\util\spyc.class.php on line 667

If this is due to the change you had done in your project’s /config/schema.yml then the problem is the syntax in your schema.yml

possibly you have written

(incorrect)

cat_id:                    { type: INTEGER, required:true, primaryKey: true}

instead of

(correct)

cat_id:                    { type: INTEGER, required: true, primaryKey: true}

here the difference between the above two line of code is: the incorrect one is having no space between required: and true, while the correct one is having the space between the two.

so whatever attributes you write leave a space between the attribute name and attribute value.

I hope this will help you out.

getting sfconfig variables from symfony app.yml of application

app.yml for your symfony application. i.e. 'frontend', 'backend' or something else

all:
  categoryPages:
    maxPages: 10  
  productPages:
    maxPages: 5  
  generalMax: 15


echo sfConfig::get('app_categoryPages_maxPages'); 
 => 10
echo sfConfig::get('app_productPages_maxPages'); 
 => 5
echo sfConfig::get('app_generalMax'); 
 => 15

how to unblock gmail blocked by system administrator

Are you frustrated of being not able to access gmail from your office or school. Follow the steps given below to unblock the access to google.

1. Try to use different url address like mail.google.com, google.com/mail, etc

below are some options for you:

· http://m.gmail.com

· https://gmail.com

· http://google.com/mail

· http://mail.google.com or https://mail.google.com

· http://googlemail.com

2. Use iGoogle

You have various gadgets available in your igoogle account. you can have a Gmail gadget added to it.

to add gmail gadget to your igoogle account please follow the steps given below:

1. Login to your iGoogle

2. go to Add Stuff screen and search for gmail gadget and add it

3. You can use Microsoft Outlook Or Other Mail Programs To Access GMail Using POP3/IMAP

4. you can use proxy websites

using a proxy website you can access any blocked site

5. The last option

this is the last option you have. lure your system administrator and develop a friendship with him. because he is the only person that will help you out with this now.

Call to undefined method sfWebRequest::hasError

Add the below given code to your <app>.class.php file:

public function setup(){
$this->enableAllPluginsExcept(array(‘sfDoctrinePlugin’));
}

::execute() must be compatible with that of sfComponent::execute()

This is since 1.1 or greater version of symfony:

class testAction extends sfAction{
public function execute() {

}

}

The above code will work fine for symfony 1.0, but for the versions above it; it won’t work.

Below given is the change you need to implement to make it work

class testAction extends sfAction{
public function execute($request) {

}

}

fatal error: call to a member function get children column() on a non-object

Below is given schema.yml of my project:

propel:
_attributes: {noXsd: false, defaultIdMethod: none, package: lib.model}
cms_admin:
_attributes:               { phpName: Admin, isI18N: true, i18nTable: cms_admin_i18n }
adm_id:                    { type: INTEGER, required: true, primaryKey: true, autoIncrement: true}
adm_email:                 { type: VARCHAR, size:100, required: true }
adm_passwd:                { type: VARCHAR, size:100, required: true }
adm_create_date:           { type: TIMESTAMP }
adm_last_login:            { type: TIMESTAMP }
adm_last_login_ip:         { type: VARCHAR, size:100 }

cms_admin_i18n:
_attributes:               { phpName: AdminI18n }
adm_id:                    { type: INTEGER, required: true, primaryKey: true  }
adm_culture:               { isCulture: true, type: varchar, size: 7, required:true, primaryKey: true }
adm_f_name:                { type: VARCHAR, size:100 }
adm_l_name:                { type: VARCHAR, size:100 }

when i tried to generate model with this schema.yml i throw me an error “fatal error: call to a member function getchildrencolumn() on a non-object”

but it was soon resolved. below is the changed schema.yml that generated a model without any errors:

propel:
_attributes: {noXsd: false, defaultIdMethod: none, package: lib.model}
cms_admin:
_attributes:               { phpName: Admin, isI18N: true, i18nTable: cms_admin_i18n }
adm_id:                    { type: INTEGER, required: true, primaryKey: true, autoIncrement: true}
adm_email:                 { type: VARCHAR, size:100, required: true }
adm_passwd:                { type: VARCHAR, size:100, required: true }
adm_create_date:           { type: TIMESTAMP }
adm_last_login:            { type: TIMESTAMP }
adm_last_login_ip:         { type: VARCHAR, size:100 }

cms_admin_i18n:
_attributes:               { phpName: AdminI18n }
adm_id:                    { type: INTEGER, required: true, primaryKey: true, foreignTable: cms_admin, foreignReference: adm_id }
adm_culture:               { isCulture: true, type: varchar, size: 7, required:true, primaryKey: true }
adm_f_name:                { type: VARCHAR, size:100 }
adm_l_name:                { type: VARCHAR, size:100 }

installing symfony plugins

To install any plugin in symfony you have to use command line interface. Here is an example how to install symfony plugins (here we’re using ‘sfGuardPlugin‘ installation) using command line interface:

1) Linux :   ./symfony plugin:install sfGuardPlugin

2) Windows:  php symfony plugin:install sfGuardPlugin

on windows if the php command is not executing you can check my blog for the same.

One more thing, if you are not having pear installed you won’t be able to install a symfony plugin through command line interface. In this case there is one more way to install symfony plugin which is given as below:

Download the plugin and extract it to the /plugin directory (folder) of the project. Now just run the following command from the command line interface:

1) Linux: ./symfony plugin:publish-assets

2) Windows: php symfony plugin:publish-assets

but before running this command you have to enable that plugin in the applications setting.yml file as below:

enabled_modules:        [default, sfGuardGroup, sfGuardUser, sfGuardPermission]
here we have enabled the sfGuardGroup, sfGuardUser and sfGuardPermission plugins.

hope this will help you out. if you have any doubt or query please contact me.

Class ‘FormFilter’ not found in symfony

Please run the commands given below :

1. *symfony propel:build-model*
2. *symfony propel:build-forms*
3. *symfony propel:build-filters*

Maybe the filter forms are not created due to any error.

Follow

Get every new post delivered to your Inbox.