johnnyevolunium johnnyevolunium - 1 year ago 108
reST (reStructuredText) Question

Structure of an API REST with Symfony3

I use Symfony for my project and I need to build an API REST.

Technically, I know how to build an API Rest but I don't know how to structurate my others bundle around API REST.

For example :


The ApiBundle allows to create/ delete/ update (etc) a Page or Comment. Do entities (and Forms) must be in ApiBundle or CommentBundle/ PageBundle ?

Answer Source

Symfony Best Practices - Organizing Your Business Logic:

For most projects, you should store everything inside the AppBundle. Inside here, you can create whatever directories you want to organize things

Basically you shouldn't make separate bundles for almost every entity (or group or entities) like Page or Comment, because they will be tightly coupled anyway. So there's no gain on that.

Actually that's one of biggest misunderstanding of what bundles are. You shouldn't create a separate bundle unless it's independent from other bundles and it's target is to be reusable and pretty generic code.

By the way I personally prefer to keep domain layer (entities e.g.) outside of any bundle. That way it's not even coupled to the framework.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download