How good is flex? The future of symfony

Since Fabien Potencier first write about symfony flex and the evolution for version 4 and above i start following the post serie and its development. Besides one or two simple tests was not able to use it for real.

Recently i start a new project that is build from scratch and since the development circle involves the launch of symfony 4 we decide to start with flex from the start, use the new project structure and be prepare for that version, and why not enjoy the journey with the new good practices and this flex flow. Another good point that set us on this path was that we will build a micro-service architecture and symfony 4 fits just fine on that pattern.

Flex is just as Fabien describes it:

Symfony Flex is all about making it simple and easy to create any Symfony applications, from the most simple micro-style project to the more complex ones with dozens of dependencies. It automates adding and removing bundles. It takes care of giving you sensible defaults. It helps discovering good bundles.

and it really what it promise, you just need to install new libs and bundles and it auto-configure it for you. The recipes published on the official repository are well integrated with this new feature, not so much the ones on the contrib repository but I think that on this earlier stage is expected to be like that and will improve for sure.

The fingerprint of a fresh installed project is now really small compared with version 3.3 and earlier, what it’s really nice for a ñn small application and even better for a micro-service.

But what about bundles that does not have a recipe yet or even those bundles that does not provide a well configured one, well it’s just Symfony at the end you can do the configuration your self it will take a bit longer but it will work as usual at the end.

Bottom line is that the future of Symfony is brilliant and I bet it will get even better. My advice take a leap of faith and use flex you will love it.


Symfony Business Model and Symfony

If you are brave enough to get out of the confort zone and structure of applications over symfony and follow a more clean path you will may be facing some challenges on the road, like integration with ORMs (Doctrine).

In this particular post i will talk about about some strategies i have follow in the past and what i have learn from it.

Business Model and Doctrine Entities/Documents

The first strategy i follow was to keep the doctrine mapping under the bundle Entity or Document directory and inherit from business clases. Given that i want to leave the business package without any reference to database or framework i choose to use yaml or xml for the mapping language instead of annotations.

The first challenge with this strategy is that objects are created on the business model so when it gets to the entity/document manager it doctrine does not recognize it and throw and error. The way i found to handle this was to implement a fromBusinessEntity function on each entity/document class so before it get persisted or updated it go through this function and convert it self to an object under the doctrine scope.

This has a big downside, since you have to convert every object and those objects may have references, embedded documents or any other complex structure it will require a big logic to handle it, and with more code comes performance degradation.

The only good side of this approach is that developers that are use to use symfony as it is and do not have interacted with a model designed by package responsibilities may feel a bit confortable on where to find the entities/documents.

Business Model as Doctrine Entities/Documents

But i cant stop with that solution i feel it was not right so i decide to dig in to the doctrine mapping configuration. My findings were that we can actually tell doctrine were to seek for mapping references so we can do something like

# Doctrine Configuration
            server: "%mongodbServer%"
    default_database: "%mongodbDatabase%"
                    type: yml
                    dir: "%kernel.root_dir%/../../BusinessPackage"
                    prefix: BusinessPackage

This way your business classes can act as doctrine entities/documents reducing complexity on your framework business integration and dropping the performance degradation that may be introduced on previous approach.


Between previous approaches i personally choose the second one because i like to keep my code as clean as possible and business independently of frameworks.

It may be even a better way to this and im counting on it, so we can keep learning and improving.

Every time we decide to use a new approach on how to deal with frameworks, architecture patterns, code structure, etc; we put our self in front of a new challenge, we may have the experience from old projects we may try new approaches, the goal must be always learn from our mistakes and improve the next phase.

Symfony validators, a tool little used

Im talking on self experience, maybe im the only one that use this amazing tool so little. But i recently i propose my self to change that and integrate it on my forms.

There are a lot of build in validators but how we can combine them and end up with a powerful validation constraints is up to us.

One of them that kept my attention and is the reason of writing this post is the CallbackValidator.

The purpose of the Callback constraint is to create completely custom validation rules and to assign any validation errors to specific fields on your object. If you’re using validation with forms, this means that you can make these custom errors display next to a specific field, instead of simply at the top of your form.

My requirement at the time was to validate and restrict two date time fields of my form called startDate and endDate respectively. The endDate as suppose cant be set to a date before the startDate field., so enter CallbackValidator

->add('startDate', DateType::class, array(
    'widget' => 'single_text',
    'format' => 'yyyy/MM/dd',
    'constraints' => array(
        new NotBlank(),
        new DateTime(array(
            'format' => 'Y/m/d'
->add('endDate', DateType::class, array(
    'widget' => 'single_text',
    'format' => 'yyyy/MM/dd',
    'constraints' => array(
        new DateTime(array(
            'format' => 'Y/m/d'
        new Callback(array(
            'callback' => function (\DateTime $endDate, ExecutionContextInterface $context) {
                $startDate = $context->getRoot()->get('startYear')->getData();
                if ($startDate > $endDate) {
                    $context->buildViolation('End date cant be before start date.')

Just as easy as that my requirements where fulfilled.

So my advice is, and to my self; please use validators.

OroPlatform an Skyscraper on top of Symfony Foundations

Say What?

OroPlatform as they show on their site:

… is an Open-Source Business Application Platform (BAP).
It offers developers the exact business application platform they’ve been looking for, by combining the tools they need. Built in PHP5 and the Symfony2 framework …

Its compose of several bundles and libraries that allows you to build “Business Applications” in less time that if you need to develop it from scratch.

As an open source project you can find its code on its github repository and read the official documentation

There are real life applications build on top of this platform:

  • OROCRM. Their main product, the name can point to its value.
  • OROCommerce: A new product also delivered by this company. A B2B e-commerce platform.
  • Akeneo: A Product Information Management platform.
  • Diamante Desk: A help desk
  • TimeLap: A module to track time in OROCRM
  • Marello: ERP for e-commerce

How do you know?

Recently i had an interaction with this platform an was both exiting and frustrating.

The Good

Easy to install

You can easily install the platform just by cloning the repository, perform a composer install and execute the symfony console command for installation or go to the browser, it will show an installation setup. You can find this steps on the official documentation

Value from the start

As previously mention, the platform its compose by several bundles that provide implementation for common tasks and easily extendable through configuration.

Right after installation you got a fully function application with a lot of values, user management and permissions, y ACL; Dashboard, Configurations, Activities, and so much more.


It provides a REST api by default and your bundles will inherit this behavior so you will be delivering a product capable of interact with the mobile world just with 0 effort.


Creating new bundles are really easy nothing different from symfony. But the power of this platform its on how you can add value to your new bundle and interact with this whole platform. You can add tags to your new entity, ownership, activities like email, notes and comments, create dashboard widgets and search over your entities. Those are just a few of the many values you can add to your bundle and to you business at the end.

The Bad

Sadly the documentation is not as detailed as we may expect. That will in many cases face us to miss incredible features or even drop it for lack of examples on how enabling it. As a platform and a open sorce project that can be use as base for many other great products it should be more documented. Maybe the community can help in this scenario.


I really recommend this project, the value you obtain with it its really big just to mention on this post, but as a user of the platform i really recommend to the developer team to focus a little bit on the docs, try to code examples of all use cases, document reference on configurations and interactions. An as a community we should also help to document it.

At the end, thanks so much oro-crm team, excellent work

Fast development vs Agile development

In the past few years i have encounter the same issue in so many different companies and so many different projects, regarding the area or scope of the project, regarding if it was an stable and profitable software solution or an start-up, regarding the experience of the project manager; the battle between fast development and agile development its the biggest issue in today development teams.

Fast development

The concept of fast development is so false as its name, but let start asking why is this requirement even born.

The quick answer is a false attempt of apply Agile development. When you are required to deliver software solutions ASAP you are basically required to “fast-develop”, but its that right?

On projects on the category of start-ups, the budget its limited and in so many cases are really small, so the client always want to deliver more with less money and faster as light.

Most of the time in this “fast-develop” attempts, we, as developers; are force to code without testing, without design patterns, without research on the state of the art on what we are doing and even without common sense.

As professionals we should not accept this and deliver software solutions with great code quality, software solutions that can be easily extensible and flexible to changes.

On my personal experience, at so many cases i was put under this circumstances and force to deliver code with so low quality that 90% of the time requires refactoring and a lot of debugging. Shame on me.

That was not fast development at all, the main propose of the “fast-development” its try to deliver software solutions that works, and hopefully wont break. But how can you accomplish this with so poor design and cero good programming practices or principles applied?

The answer its clear, you can’t.

Agile Development

Agile does not mean fast, agile is about moving quickly and easily.

At software industry agile means to build the software solution step by step, delivering value at each step but taking all the measures to deliver it right.

That means, take the time to research, the time to design, the time to apply good programming practices and principles, the time to take choices with care, to think on value, to build good software solutions.

Its actually accountable that projects build upon Agile are in fact faster that those who use “fast-development”.

I took this little experiment on one project some time ago. I was team lead at the time and the team was using or at least trying to use SCRUM, so i begin to measure how fast the team was: based on if the team delivers or not on each sprint and how much fix of that value need to be re-introduce on the next sprint. The result was on a 40%-50% of that value, so in terms on how fast the team was the answer its cristal, only %50 fast.

So with that results over 4 whole sprints i propose a plan to actually be agile and deliver a good value for the same time as the first test, notice that the project was the same, an the team was the same, only the strategy changes. We now schedule time to discuss the solution, to research, to apply design patterns and to test the code. The measures where the same as the first scenario. The results where amazing, the team was 30%-40% faster at the first sprint, 40%-50% faster at the second sprint and 50%-60% faster at the two last sprints. Given that the team was force to think in another direction and we where working with a really bad legacy code, the results where amazing, the team was able to increase the speed at the end.

So what happens, the team keeps working on that bases and having a good retrospective at the end of the sprint, trying to look at sings that may lead to use the bad practices.

So as Robert C. Martin (Uncle Bob) advice on so many of his books and conferences:

By been agile, by applying design patterns and test your code; you will actually been faster by been slow

At the end even on those start-up projects with very limited budget use agile will provide a solution that ensure the quality that the client was expected from the start.


I know that much of this have its roots on professionalism and experience, but we should always look on better ways to do things, to build things. We need to encourage our self to battle and discuss the right ways, that is what make us professionals in the first place.

As a Software Engineer and as a Professional i toke a personal stance to explain, advice, educate and finally agree to code using Agile Development delivering software solutions at the greatest quality i can.