2. Serial entrepreneur
Developer by passion
Founder of Sensio
Creator and lead developer of Symfony
On Twitter @fabpot
On github http://www.github.com/fabpot
http://fabien.potencier.org/
The Symfony Components – Fabien Potencier
3. Standalone components for PHP 5.3
No dependency between them
Used extensively in Symfony 2, the framework
The Symfony Components – Fabien Potencier
18. SymfonyFoundationKernel > Symfony/Foundation/Kernel.php
DoctrineDBALDriver > Doctrine/DBAL/Driver.php
pdependreflectionReflectionSession > pdepend/reflection/ReflectionSession.php
Vendor name
The Symfony Components – Fabien Potencier
19. PHP 5.3 technical interoperability standards
« … describes the mandatory requirements
that must be adhered to
for autoloader interoperability »
http://groups.google.com/group/php-standards/web/psr-0-final-proposal
The Symfony Components – Fabien Potencier
57. $application = new Application('Life Tool', '0.1');
The Symfony Components – Fabien Potencier
58. class WeatherCommand extends Command
{
protected function configure()
{
$this->setName('weather')
->setDescription('Displays weather forecast')
->setHelp(<<<EOF
The <info>weather</info> command displays
weather forecast for a given city:
<info>./life weather Paris</info>
You can also change the default degree unit
with the <comment>--unit</comment> option:
<info>./life weather Paris --unit=c</info>
<info>./life weather Paris -u c</info>
EOF
);
}
The Symfony Components – Fabien Potencier
61. $ ./life weather
$ ./life weath
$ ./life w
The Symfony Components – Fabien Potencier
62. Console
The Input
The Symfony Components – Fabien Potencier
63. class WeatherCommand extends Command
{
protected function configure()
{
$definition = array(
new InputArgument('place',
InputArgument::OPTIONAL, 'The place name', 'Paris'),
new InputOption('unit', 'u',
InputOption::PARAMETER_REQUIRED, 'The degree unit',
'c'),
);
$this->setDefinition($definition);
The Symfony Components – Fabien Potencier
128. Wraps template variables
Works for
strings
arrays
objects
properties
methods
__call(), __get(), …
Iterators, Coutables, …
…
Works for deep method calls
The Symfony Components – Fabien Potencier
131. class Article
{
protected $title;
protected $author;
public $full_title; public property
public function __construct($title, Author $author)
{
$this->title = $title;
$this->full_title = $title;
$this->author = $author;
}
public method
public function getTitle() { return $this->title; }
public function getAuthor() { return $this->author; } public method returning
public function __get($key) { return $this->$key; } another object
public function __call($method, $arguments)
{ magic __get()
return $this->{'get'.$method}(); magic __call()
}
}
The Symfony Components – Fabien Potencier
132. class Author
{
protected $name;
public function __construct($name) { $this->name = $name; }
public function getName() { return $this->name; }
}
The Symfony Components – Fabien Potencier
133. use SymfonyComponentsOutputEscaperEscaper;
$article = new Article(
'foo <br />',
new Author('Fabien <br />')
);
$article = Escaper::escape('htmlspecialchars', $article);
echo $article->getTitle()."n";
echo $article->getAuthor()->getName()."n";
echo $article->full_title."n";
echo $article->title."n";
echo $article->title()."n";
The Symfony Components – Fabien Potencier
134. explicitly ask
for raw data
echo $article->getHtmlContent('raw');
echo $article->getTitle('js');
change the default
escaping strategy
The Symfony Components – Fabien Potencier