Category Archives: Symfony

Symfony – Creating a New Plugin

You need this just once: _ sudo apt-get install php-pear _ sudo pear channel-discover plugins.symfony-project.com For every package: _ Create the file package.xml and put it on the root of the plugin _ launch:      pear package To update the repository, … Continue reading

Posted in Symfony | Leave a comment

Sympony – Propel – Get Connection Details

/** * Returns an associative array with the details of the database connection * * @param string $application the name of a valid application (i.e.: frontend) – used to get a Propel connection * @param string $environment the environment we … Continue reading

Posted in Symfony | Leave a comment

Symfony – Hydrated Criteria

public static function getHydratedCriteria() { $criteria = new Criteria(); $criteria->addSelectColumn(‘*’); $criteria->setPrimaryTableName(self::TABLE_NAME); $criteria->addJoin(self::COMPANY_ID, CompanyPeer::ID, Criteria::INNER_JOIN); $criteria->addJoin(self::CITY_ID, CityPeer::ID, Criteria::INNER_JOIN); $criteria->addJoin(self::REGION_ID, RegionPeer::ID, Criteria::INNER_JOIN); return $criteria; }

Posted in Symfony | Leave a comment

Lucene PHP – Important Notes

*** Lucene – Use integers *** Actually the book ‘Practical Symfony’ (version jobeet-1.2-propel-en-2009-02-05) is not accurate: 1) the primary key should be defined as a Keyword $doc->addField(Zend_Search_Lucene_Field::Keyword(‘pk’, $this->getId())); 2) by default, Lucene can’t find numbers in its index [and a … Continue reading

Posted in Symfony | Tagged | Leave a comment

Symfony and Eclipse – Include Library

To include Symfony library: ‘Add External Source Library’ during the creation of the project

Posted in Symfony | Tagged | Leave a comment

Symfony – Admin on a Subset of Rows, Extra Criteria

In the actions.class.php, you need to override the method buildCriteria, adding the criteria you need

Posted in Symfony | Leave a comment

Propel – Sympony – Conditions in OR in Criteria

Propel: $c = new Criteria(); $cton1 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, “Leo”); $cton2 = $c->getNewCriterion(AuthorPeer::LAST_NAME, array(“Tolstoy”, “Dostoevsky”, “Bakhtin”), Criteria::IN); $cton1->addOr($cton2); // add to Criteria $c->add($cton1); $authors = AuthorPeer::doSelect($c);

Posted in Symfony | Leave a comment

Custom SQL on Symfony

$c = new Criteria(); $c->addAsColumn(‘total_views’, ‘SUM(‘ . self::VIEWS . ‘)’); $c->addAsColumn(‘yearAndMonth’, ‘SUBSTR(‘ . self::TIME . ‘, 1, 7)’); $c->add(self::OFFER_ID, $offer->getId()); $c->addGroupByColumn(‘yearAndMonth’); $c->addDescendingOrderByColumn(‘yearAndMonth’); $viewsForMonths = array(); $stmt = BasePeer::doSelect($c); while($result = $stmt->fetch(PDO::FETCH_ASSOC)) { list($year, $month) = explode(‘-’, $result['yearAndMonth']); $monthString = date(‘F’, … Continue reading

Posted in Symfony | Leave a comment

Symfony – Get the Working Environment

$sf_environment = sfConfig::get(’sf_environment’);

Posted in Symfony | Leave a comment

Symfony – how to Include a Partial into an External Web Site – Symfony Integration

This is very good for integrating the header of a web site powered with Symfony in a WordPress blog. That is just an example require_once(dirname(__FILE__).’/../config/ProjectConfigurat ion.class.php’); $configuration = ProjectConfiguration::getApplicationConfiguration(‘frontend’ , ‘dev’, true); sfContext::createInstance($configuration); // Remove the following lines if you … Continue reading

Posted in Symfony | Leave a comment