Before Symfony was spelled with a capital “S” there was another symfony, the first version of the framework. It already meant a lot to me at the time. But with the arrival of Symfony 2 it became clear that something very important was happening in the world of PHP programming. It appears that this framework is able to turn amateur website makers (like I used to be) into actual software developers. What is the secret? What makes Symfony so special? And why am I still hooked?
We’ll look at pieces of code, the Symfony ecosystem, the people behind it, the things that have been written about it, and the experience that I have with it. We’ll take a trip down memory lane, collecting pieces for our Symfony scrapbook, while we try to construct an answer to these questions.
16. Working with
symfony 1 meant...
MVC
Fat controllers
Fat models
(Zend devs wrote fat services as well)
17. Not in the controller
or the model?
Put it in:
A "peer" class
A utility class
Or: create a global singleton for it
18. What's a singleton?
Static
Global
Single
instance
class Singleton
{
private static $instance;
private function __construct()
{
}
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
}
34. Infrastructure
1. Git for version control
2. Install script or Git
submodules for vendor
code
3. At some point:
composer started
handling dependencies
38. What's a DI
container?
class Container
{
public function createFoo()
{
return new Foo($this->getBar());
}
private function createBar()
{
return new Bar();
}
}
39. What does DI give
us?
Single responsibility
Testability
Dependency inversion
Speed
Flexibility