Installing Symfony Flex and Prooph 7

Because I love to experiment with new technologies I decided today to set up a new event-sourced project using Symfony Flex and Prooph 7. In this blog post, I am going to describe my experiences when installing these, which issues I encountered and how I resolved them. Keep in mind that the contents of this post will probably be outdated in a couple of months.

Setting up Symfony Flex

Installing Symfony Flex was super easy, all I had to do was:

composer create-project symfony/skeleton my-project

And presto: I had a new project! (don’t be like me, replace the my-project with your own project name.)

I followed the instructions that came after installing Symfony Flex, started PHP’s internal web server and was surprised to see an error 404 when I went to “localhost:8000”. Apparently, Symfony Flex doesn’t come with a controller as it used to be in previous versions. No biggy, I just now know that until I add a controller I get a “page not found” message.

Setting up Prooph

Now, onto Prooph! After checking their website how you install Prooph into Symfony and I was directed to their Proophessor example project for Symfony. Unless I am missing something, it was grossly out of date as it contained a relatively old version of the bundles that Prooph uses to interface with Symfony.

Because I wanted to use the latest version of everything, I manually installed the “prooph/event-store-symfony-bundle” package, and the “prooph/service-bus-symfony-bundle”. Then I hit another snag:

Then I hit another snag: The latest tagged versions of these bundles are not compatible with each other, and they did not install Prooph 7. Apparently, the Prooph devs are hard at work fixing this because I could resolve it by manually adding the following lines to my composer.json:

"prooph/event-store-symfony-bundle": "dev-master@dev",
"prooph/service-bus-symfony-bundle": "dev-master@dev",

and then I ran “composer update” to install these packages after all.

Unfortunately, the “composer update” task failed with this weird error message:

!! PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "EventStore" from namespace "Prooph\Bundle\EventStore".
!! Did you forget a "use" statement for "Prooph\EventStore\EventStore"?

Symfony Flex tries to infer the Bundle’s class name as part of the installation process to automatically add the bundle to Symfony. It would seem that Symfony Flex incorrectly infers the information for these two bundles.

To fix this situation: you have to update the file “config/bundles.php” and remove the current mentions of Prooph, and replace them with these two lines:

 'Prooph\Bundle\ServiceBus\ProophServiceBusBundle' => ['all' => true],
 'Prooph\Bundle\EventStore\ProophEventStoreBundle' => ['all' => true],

After I did this I ran “composer update” again and the error message disappeared.


This is how far I got thus far. Even though I hit a couple of snags, I did get my application setup for the most part without too much trouble. I like how clean the Symfony directory structure is and once they manage to iron out the bugs on inferring class names, it should be smooth sailing.

Next up for me is setting up Doctrine and running the app from Docker. Until next time!

One thought on “Installing Symfony Flex and Prooph 7

Comments are closed.