Symfony

Symfony is a PHP Framework. It uses Propel to achieve outstanding (really?) workflow possibilities, making database-based websites easy and fast to develop. At least let's hope so…

Stones in your way

Resources

Edit the memory limit. 16MB (default) seems to be not enough.

sudo vim /etc/php5/apache2/php.ini

and

sudo vim /etc/php5/cli/php.ini
memory_limit = 128M

Installation

sudo pear channel-discover pear.symfony-project.com
sudo pear install symfony/symfony-1.2.7

symfony -V should show version 1.2.7

Needed for some unit-tests:

sudo aptitude install php5-xdebug

Deployment to Win/Xampp

  • PATH: append c:\xampplite\php
  • copy: c:\xampplite\htdocs\symfonyproject\lib\vendor\symfony\data\bin\symfony.bat → c:\xampplite\htdocs\symfonyproject
  • php.ini: short_open_tag = On

DB

Choose Symfony Database

symfony configure:database "<dbtype>:dbname=<dbname>;host=<host>" <login> <password>
<dbtype> - mysql, pqsql, …

Initiate DB

  1. Create DB Scheme (scheme.yml)
  2. symfony propel:build-sql
  3. symfony propel:insert-sql
  4. symfony propel:data-load (loads fixtures from data/fixtures)
  5. mysql -h <host> -u <user> -p <dbname> < data.sql (data only contains inserts)

Initiate Symfony from a existing DB

  1. Configure database access
  2. symfony propel:build-model creates new schema.yml from the layout of the DB

Netbeans

symfony -V reveals the path of the framework, e.g. /usr/share/php/symfony

In Netbeans create a new project using existing project directory. Navigate the folder where the project is stored in. The path to the framework has to be added to the include path in Netbeans to get code completation to work properly.

Average

<?php
// BlaPeer.class.php
static public function getAverageColumn(PropelPDO $con = null)
{
   if($con === null) {
      $con = Propel::getConnection(BlaPeer::DATABASE_NAME, Propel::CONNECTION_READ);
   }
 
   $stmt = $con->prepare('SELECT AVG(' . BlaPeer::POTENZIAL . ') FROM ' . BlaPeer::TABLE_NAME);
   $stmt->execute();
   return $stmt->fetchColumn();
}
 
// call i.e.:
$avg = BlaPeer::getAveragePotenzial();
?>

Min/Max

//Smallest Value
<?php
$c = new Criteria();
$c->add(BlaPeer::Bla_ID, $this->getId());
$c->addAscendingOrderByColumn(BlaPeer::COLUMN);
return BlaPeer::doSelectOne($c);
?> 
symfony.txt · Last modified: 2010/07/01 16:38 (external edit)
CC Attribution-Noncommercial-Share Alike 3.0 Unported chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0