xml parser in php

There is a build in function in php using which you can parse xml file to an array. I have an example created for the same, and it goes as mentioned below:

$xmlString = $raw;
$xmlParser = xml_parser_create();
xml_parse_into_struct($xmlParser, $xmlString, $values, $main);

echo “<b>Main array</b><br>”;
echo “<br>”;
echo “<b>Values array</b><br>”;


Sachin (http://www.avidindiainc.com)

installing pear packages on windows / wamp

first of all start the command line from windows:  click “start” and then “run”; now type “cmd” and press the enter key.

type “pear install <packagename>” (where<packagename> is the name of the package you want to install)

if the above one does not work, manually download the package from the website and got to that directory that contains the downloaded package.

and type “pear install <packagename>”(where<packagename> is the name of the downloaded package)

install pear on windows / wamp

first of all start the command line from windows:  click “start” and then “run”; now type “cmd” and press the enter key.

now go to the directory which contails the php files. in my case i had wamp installed so it was in c:/wamp/bin/php/php5.2.8

now type go-pear” and press the enter key.

Edit the `include_path=".;c:\wamp\bin\php\php5.2.6\pear"` variable in your php.ini file and then restart your server.

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


class: sfConsoleController
class: sfConsoleRequest
class: sfConsoleResponse

class: sfSessionTestStorage

#  controller:
#    class: sfFrontWebController
#  request:
#    class: sfWebRequest
#  response:
#    class: sfWebResponse
#  user:
#    class: myUser
class: sfSessionStorage
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:

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

or as a short hand for the above

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


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


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

instead of


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.

::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) {