-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symfony Flex Recipe #41
Comments
Is there any configuration needed, which could be done by the recipe? |
To be honest I don't see anything that might be configured out of the box.
This would allow beginners to quickly dive into prooph without much knowledge. |
@UFOMelkor great idea, really like it and yes MySql should be the default because reasons ;) |
Hello there! I'm currently digging into Symfony flex recipe creation and wanted to give it a try for Prooph!
Is there another on-going initiative which covers this issue? (1) This is inspired by https://github.com/php-http/httplug-flex-pack, I haven't found documentation about creating a flex pack yet. |
When someone will run That's how I think it would work, I'm currently reading and trying it out to see if this is really how it'll behave. If someone has more xp about it, I'd be happy to share some thoughts! |
Heads up:
|
Hello, I have a confrmation that the flex recipe mecanism works as I believed it would. Here's what I get so far: $ SYMFONY_ENDPOINT=https://symfony.sh/r/github.com/symfony/recipes-contrib/320 composer.phar require "gquemener/pdo-event-sourcing-pack:*@dev"
Warning: Using https://symfony.sh/r/github.com/symfony/recipes-contrib/320 as the Symfony endpoint
./composer.json has been updated
Warning: Using https://symfony.sh/r/github.com/symfony/recipes-contrib/320 as the Symfony endpoint
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 13 installs, 0 updates, 0 removals
- Installing beberlei/assert (v2.9.3): Loading from cache
- Installing paragonie/random_compat (v2.0.11): Loading from cache
- Installing ramsey/uuid (3.7.3): Loading from cache
- Installing prooph/common (v4.2.1): Loading from cache
- Installing marc-mabe/php-enum (v3.0.0): Loading from cache
- Installing prooph/event-store (v7.3.2): Loading from cache
- Installing prooph/pdo-event-store (v1.7.2): Loading from cache
- Installing prooph/service-bus (v6.2.2): Loading from cache
- Installing prooph/event-store-bus-bridge (v3.1.0): Loading from cache
- Installing prooph/event-sourcing (v5.3.0): Loading from cache
- Installing prooph/event-store-symfony-bundle (v0.4): Loading from cache
- Installing prooph/service-bus-symfony-bundle (v0.6.0): Loading from cache
- Installing gquemener/pdo-event-sourcing-pack (dev-master 2f8347f): Loading from cache
Writing lock file
Generating autoload files
Symfony operations: 2 recipes (117325007f3b3255fa1de7ad69822929)
- Configuring prooph/event-store-symfony-bundle (>=v0.4): From auto-generated recipe
- Configuring prooph/service-bus-symfony-bundle (>=0.6): From github.com/symfony/recipes-contrib:320
Executing script cache:clear [OK]
Executing script assets:install --symlink --relative public [OK]
Some files may have been created or updated to configure your new packages.
Please review, edit and commit them: these files are yours. And a command bus (named @prolic or @codeliner, could you create a repository under the prooph org against which I could PR the content of https://github.com/gquemener/prooph-pack please? |
@gquemener repo is here: https://github.com/prooph/prooph-pack @prooph/symfony-team has write access ^^ |
@codeliner Perhaps pdo-event-sourcing-pack is a better name? |
@codeliner Maybe |
@sandrokeil looks like the recipes are called "pack", see httplug-pack |
Ok so better two packs instead of one?
|
As far as I undeserstand, Technically, it's possible to not rely on Anyway, I've started to focus on the service-bus-symfony-bundle recipe.
I don't think it's quite possible to do something like "register an event bus only when the event-sourcing pack is required". The same recipe will be applied when the bundle is installed, no matter which pack requires it (I could be wrong though...). I haven't put my fingers in the components for a few months, so I'd like your thoughts about these features, please 👍 |
Point number 4 is problematic because we cannot provide a From then, our only option to register the command handler services is in a file inside the But, because the default Kernel loads the It's a tricky problem, I hope I make sense! So far, I've found a few solutions to this problem: Provide a Provide the command handler definition in a file in inside the Provide nothing and display in a message at the end of the installation the yaml to auto register all command handlers. What do you think? |
Second option: displaying a message sounds good But I'm not an expert in this area. Hopefully @UFOMelkor can say more |
After thinking about it, we might be able to provide different configuration sets depending on which pack is required (by defining a recipe for this pack, and not for the bundles contained in the pack), But, that'd be overkill, don't you think? I think I'm missing experience on Prooph to know what out-of-the-box configuration would improve DX 🤔 |
With my current knowledge, I would forget the packs and provide recipe for the prooph bundles that setup basic configurations (inspired by their Getting started documentation for example). |
I've put a lot of thoughts into this question lately and started to work on a beginner friendly ready-to-use package called Event Machine (not symfony related) and a preconfigured skeleton: https://github.com/proophsoftware/event-machine-skeleton But this package is a framework in itself ^^. It is based on prooph components but uses them in a certain way. A lot of decisions are made upfront so that new users don't need to think about it but just start working with the skeleton and build something awesome. The downside of this approach is, that you loose flexibility. One example: Another example is that Event Machine only uses one command bus, one event bus and one query bus for the entire application/service. Again, this works pretty well for mid-sized applications and/or (micro)services, but is not so good for monolithic systems split into code modules. As far as I understand a recipe tries to do the same thing: Provide some good defaults so that developers can start right away. For a microservice with its own database the set up described above is really everything you need. How does the doctrine recipe solve the issue? Maybe the result is, that a good default recipe can not be provided for prooph. Or the majority of symfony devs say that a single bus and an event store with only one stream are a good start. |
I've looked in many recipes to see how one would register services with classes from the For instance, doctrine only register services from the Maybe it's a bad idea 🤔 I will take a look on Event Machine tomorrow 👍 |
IMHO such a pack should have two main purposes: It should allow a faster trying out and take copy and paste configuration off my hands. The actual effort to start with full prooph in symfony is:
(1)-(4) are tasks which are down rarely (once for an application) while (5) is the daily work.
Nothing prevents you from adding multiple buses / event stores.
No, my propose is just one package named pdo-event-sourcing-pack. |
Hello @UFOMelkor, I completely agree with all you say, that'll be a great way to get started in a symfony / prooph project. I'd like to add a few things. Pack vs SkeletonI'm not sure if the good solution wouldn't be to create a symfony skeleton project, instead of a pack. Here's an example of skeleton: https://github.com/symfony/website-skeleton/blob/4.0/composer.json. A Prooph symfony skeleton project would allow to start faster coding: $ composer create-project prooph/symfony-skeleton my-project
$ cd my-project
$ vim A pack would require to perform something like this: $ composer create-project symfony/website-skeleton my-project
$ cd my-project
$ composer require prooph/symfony-pack
$ composer remove orm (+ everything else uneeded)
$ vim The downside of a skeleton is that I don't think it's made to be required on existing project (whereas symfony packs are), but the main idea here is to get started faster, isn't it? Bundle-wide vs Pack/Skeleton-wide recipesIt seems that Symfony Flex can execute recipes no matter if the package is a library or a bundle. However, I think this system has a flaw because it creates recipe dependencies. In the case of Prooph, if we follow the same example, it would mean creating a My suggestion would be to define one skeleton/pack-wide recipe, executed only when requiring the skeleton/pack. The downside is that this recipe wouldn't be executed when requiring packages manually, but is it really a problem? Another suggestion would be to define recipes ONLY for prooph bundles. Current statusSo far, I've managed to configure a command bus and auto-register command handlers => symfony/recipes-contrib#320. I've also realised that prooph service definition still use the old id "convention", new one being to use the FQCN (leveraging autowiring). This leads me to manually create alias to enable autowiring: services:
Prooph\Common\Messaging\MessageFactory: '@prooph_event_store.message_factory' Is there any reason for that? Should I investigate further and create a PR to switch to FQCN ids? Last but not least, do you have an idea about what happened to the |
You haven't mentionned registering the command, event, query handlers. Do you think it's a bad idea to provide default configuration for this? |
Pack vs SkeletonMy personal opinion: Having both would be great, but would double the effort of maintenance. Bundle-wide vs Pack/Skeleton-wide recipes
The only alternative I see is to create a recipe for
which all ship their own config and add a pack which just requires the right packages (like the debug-pack does). But this would require more recipes and therefore more configuration files (4) and would come to the same result in most cases. 👍 for one pack with one recipe. Current status
I'll check tomorrow but first impression looks good :-)
For bundles the old id convention is still actual, but we miss aliases for public services (see https://symfony.com/doc/current/bundles/best_practices.html#services); this leads us to the question which services should be public, but IMHO the MessageFactory is one.
I hid it behind (5): Add Aggregates, Commands, Command Handlers, Repositories, ... 😉 I don't think that it is wrong, but that it won't help very much. Either you have to recognize were to put your handlers and modify this or you have to learn how to configure this (which you easy and you need to learn anyway). Might be that I'm just to informal? |
Allright, maybe when there will be more maintainers on the project then 😉
Let's go 👍
I skipped this part, thanks for pointing that out.
Indeed. |
Would be great 👍
Good idea 👍 |
We should think about adding a recipe for the bundle to the recipes contrib repo
The text was updated successfully, but these errors were encountered: