Image

Symfony

Enable sqlite pdo sqlite

By  •  Symfony

You need to enable either the SQLite or PDO_SQLite extension for the profiler to run properly.

sudo apt-get install php5-sqlite

restart apache

How to set default application for a Symfony project

By  •  Symfony

Pointing your browser to the root directory of your Symfony project will bring you to the module default of the first app you created for the project. The following is the content of the file web/index.php in your Symfony’s project folder;

<?php


require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');

$configuration = ProjectConfiguration::getApplicationConfiguration('admin', 'prod', false);
sfContext::createInstance($configuration)->dispatch();

In the example, the default app is admin. To make it load the app frontend for example, just replace admin in the file with frontend, and you’re all set.

How to use transaction in Symfony with Doctrine

By  •  Symfony

The following code explains for itself in using simple transaction with Doctrine 1.x ORM in Symfony.

$conn = sfContext::getInstance()->getDatabaseManager()->getDatabase('doctrine')->getDoctrineConnection();
 
try {
	$conn->beginTransaction();
 
	// The part where you want to do transaction. Add your codes here
 
	// Commit the transaction when done
	$conn->commit();
 
} catch (Doctrine_Exception $e) {
	// Rollback if transaction fail
	$conn->rollback();
} 

Please help expand this article

How to set default module for a Symfony application

By  •  Symfony

If not specified, Symfony will load the application’s default module if no action is defined in the URL. The default module will show this page,

which might not be very useful to the visitors.

By default, your routing configuration file (apps/yourapp/config/routing.yml) is as the following;

# You can find more information about this file on the symfony website:
# http://www.symfony-project.org/reference/1_4/en/10-Routing

# default rules
homepage:
  url:   /
  param: { module: default, action: index }

# generic rules
# please, remove them by adding more specific rules
default_index:
  url:   /:module
  param: { action: index }

default:
  url:   /:module/:action/*

To make it default to the module mypage for example, edit the route homepage and replace default with mypage.

Top