Skip to content

Instantly share code, notes, and snippets.

@unixmonkey
Created December 13, 2012 20:28
Show Gist options
  • Select an option

  • Save unixmonkey/4279507 to your computer and use it in GitHub Desktop.

Select an option

Save unixmonkey/4279507 to your computer and use it in GitHub Desktop.
Notes on Symfony 1.4 development that I keep finding myself having to look up

RESOURCES

A Gentile Introduction to Symfony

The Definitive Guid to Symfony

The Symfony 1.4 Reference Book

Customizing the Web Debug Toolbar

DEBUGGING and LOGGING

The Definitive Guide to Symfony

// From an action
$this->debugMessage($message, 'err');

// From a view
<?php use_helper('Debug'); debug_message($message) ?>
// or
<?php use_helper('Debug'); log_message($message, 'err') ?>

// From a controller
$this->getLogger()->alert($message);

// From anywhere
echo("<pre>".$message."</pre>\n"); exit();

Get current route name

sfContext::getInstance()->getRouting()->getCurrentRouteName(); #=> 'default_index'
// From controller
$this->getRequest()->getPathInfo(); #=> '/home'

Get Running Environment

sfConfig::get('sf_environment') #=> 'test'

Run a Task in code or test

$task      = new nameOfMyTask($configuration->getEventDispatcher(), new sfFormatter());
$arguments = array();
$options   = array('env' => 'test');
$task->run($arguments, $options); // run the task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment