docs(articles): English translation of From Magento to Symfony
en/articles/magento-to-symfony/basics/mindset.md
new file +27
−0
A change of mindset
Magento is a finished product that you extend without touching the core. That is why it has so many ways to intervene: plugins on any public method, preferences, layout XML, EAV, admin config with scopes.
Symfony is a set of components from which you assemble your own application. There is no core as a product: the code in src/ is the application, you own it and simply change it. So there are far fewer ways to intervene, and behavior is more explicit: what you see in the constructor and the configuration is what runs.
Most Magento-style "how do I intercept X" questions turn into "just change your code" in Symfony. Interception is only needed for code in vendor/, and there are three tools for it: an event, a decorator, a service override.
Carries over almost unchanged
- Constructor dependency injection, programming to interfaces. Magento taught you this, Symfony rewards it.
- Composer, PSR-4,
Psr\Log\LoggerInterfaceand Monolog are the same. bin/magentois built on Symfony Console. A command class looks almost the same.- Thinking in events and observers.
- Message queues, retries, separate workers.
- PHPUnit, PHPStan, PHP-CS-Fixer.
You need to unlearn
- ObjectManager and generated code:
Factory,Proxy,Interceptoringenerated/. getData()/setData(),DataObjectand magic getters.- Plugins on any method of any class.
- XML for everything. In Symfony most configuration is PHP attributes next to the code, the rest is YAML.
- An interface in
Api/Datafor every entity. Service contracts are optional here. - EAV, store/website scopes, admin settings, indexers, modes. They don't exist, and you shouldn't build them without a real need.