0

How do I build my application hierarchy modular, having separated modules which are more plug n' play-ish.

I would like to have a structure like this:

- assets
- bin
- config
- migrations
- public
- src
| - Controller
| - Entity
| - Repository
| - Modules
  | - Example_Module
    | - public
      | - js
      | - img
      | - css
    | - src
      | - Controller
      | - Entity
      | - Repository
    | - templates
- templates
- var
- vendor  

How do I set this up in Symfony?

3
  • Topics to start with: DDD & Hexagonal arch. Commented Aug 14 at 7:43
  • What is the use case that you think such structure is more preferable than putting each module in a separate repo and using it as a Composer dependency or a microservice? Commented Aug 14 at 8:02
  • @iloo: I can't clarify that for the questions author, but often that is to "defer the details until later". Asking for plug'n'play-ability is a very strong hint the OP wants to work with that technique - whether it's a known technique or not. It also prevents awkward design thinking and henceforth decisions: Asking for a composer dependency for modules for example can lead to blindness locating both the project and it's dependencies first of all - Composer is only a tool you can choose to manage them (both!). And what can possibly go wrong with asking for microservices? Commented Aug 14 at 8:35

1 Answer 1

1

How do I set this up in Symfony?

TLDR:

composer create-project

Long answer:

Symfony historically (S1) is a classic MVC framework strongly in relation to ZF1 which came two weeks earlier.

Since S2 it bought more into a class-path based framework of components building upon it's own base library that are more easily compose-able with its own and other class- and object trees, so either your own or those of other third-party libraries, for example Doctrine.

While making that design decision, it strongly influenced the design and implementation of the Composer utility.

What you describe as plug'n'play-ish commonly maps onto class- and object- tree based libraries that can be used with dependency injection to rely on plugin-in interfaces instead of more concrete implementations.

Symfony provides the infrastructure for that within its framework ("Services").

Henceforth, you can not only answer that question by studying the history of the Symfony framework and its utilities, but also their documentation for the answer of your question and by making active use of the Composer utility.

Rest assured, that for roughly 90% of your questions, a documented answer exists, most likely with code examples and other kind of instructions. And that for 90% of the functionality you need, implementations already exist.

The last 10%, which will consume 90% of the time you still need to spend on your project, we have to always do it with love, pain and hard work.

Symfony homepage: https://symfony.com/

Symfony services: https://symfony.com/doc/current/service_container.html

Symfony kernel configuration: https://symfony.com/doc/current/reference/configuration/kernel.html

Sign up to request clarification or add additional context in comments.

1 Comment

Another answer could also be to make use of a meta-framework that is past the first iteration to make Symfony more plug-n-play-ish as a framework itself: Laravel. (Turtles all the way down)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.