ORO Meetups - Symfony2 Worst Practices

Preview:

Citation preview

Symfony Worst Practices

Worst Practices

Michael Sulimamsulima@magecore.com

Symfony Worst Practices

Don’t use this tool

Symfony Worst Practices

Fat Stupid Ugly Controllers

Symfony Worst Practices

Fat Stupid Ugly Controllers■ Use single responsibility principle also for controller actions

■ Do not start coding in controllers

■ Do not create forms in controllers

■ Extract your shared methods or avoid them at all

■ Go the test driven way

Symfony Worst Practices

Doctrine likes memory

Symfony Worst Practices

Doctrine likes memory

■ Avoid Object Hydration when handling many entities

■ Don’t load the whole entity if you only need reference to it

■ Do not flush inside cycles

Symfony Worst Practices

Fat DI Container

■ Controllers as services

■ Single use forms

■ Do not create parameter if you will never needed to change that value

Symfony Worst Practices

Circle dependency between bundles

Symfony Worst Practices

Don’t inject DIC into services

Symfony Worst Practices

Using Object Manager■ Do not inject Object Manager into entities

■ Do not inject Object Manager into services

Symfony Worst Practices

Binding to the Environment

Symfony Worst Practices

Using data in form constructors

Symfony Worst Practices

Q & A

Symfony Worst Practices

No?