Creating a Bug ReproducerEdit this page
Warning: You are browsing the documentation for Symfony 3.2, which is no longer maintained.
Read the updated version of this page for Symfony 6.1 (the current stable version).
The main Symfony code repository receives thousands of issues reports per year. Some of those issues are so obvious or easy to understand, that Symfony Core developers can fix them without any other information. However, other issues are much harder to understand because developers can't easily reproduce them in their computers. That's when we'll ask you to create a "bug reproducer", which is the minimum amount of code needed to make the bug appear when executed.
If you are reporting a bug related to some Symfony component used outside the Symfony framework, it's enough to share a small PHP script that when executed shows the bug:
1 2 3 4 5 6 7 8 9 10 11 12 13
// First, run "composer require symfony/validator" // Then, execute this file: require_once __DIR__.'/vendor/autoload.php'; use Symfony\Component\Validator\Constraints; $wrongUrl = 'http://example.com/exploit.html?<script>alert(1);</script>'; $urlValidator = new Constraints\UrlValidator(); $urlConstraint = new Constraints\Url(); // The URL is wrong, so var_dump() should display an error, but it displays // "null" instead because there is no context to build a validator violation var_dump($urlValidator->validate($wrongUrl, $urlConstraint));
If the bug is related to the Symfony Framework or if it's too complex to create a PHP script, it's better to reproduce the bug by forking the Symfony Standard edition. To do so:
- Go to https://github.com/symfony/symfony-standard and click on the Fork button to make a fork of that repository or go to your already forked copy.
- Clone the forked repository into your computer:
git clone git://github.com/YOUR-GITHUB-USERNAME/symfony-standard.git
- Browse the project and create a new branch (e.g.
- Now you must add the minimum amount of code to reproduce the bug. This is the trickiest part and it's explained a bit more later.
- Add, commit and push all your changes.
- Add a comment in your original issue report to share the URL of your forked
https://github.com/YOUR-GITHUB-USERNAME/symfony-standard/tree/issue_23567) and, if necessary, explain the steps to reproduce (e.g. "browse this URL", "fill in this data in the form and submit it", etc.)
The key to create a bug reproducer is to solely focus on the feature that you suspect is failing. For example, imagine that you suspect that the bug is related to a route definition. Then, after forking the Symfony Standard Edition:
- Don't edit any of the default Symfony configuration options.
- Don't copy your original application code and don't use the same structure of bundles, controllers, actions, etc. as in your original application.
- Open the default controller class of the AppBundle and add your routing definition using annotations.
- Don't create or modify any other file.
- Execute the
server:runcommand and browse the previously defined route to see if the bug appears or not.
- If you can see the bug, you're done and you can already share the code with us.
- If you can't see the bug, you must keep making small changes. For example, if your original route was defined using XML, forget about the previous route annotation and define the route using XML instead. Or maybe your application uses bundle inheritance and that's where the real bug is. Then, forget about AppBundle and quickly generate a new AppParentBundle, make AppBundle inherit from it and test if the route is working.
In short, the idea is to keep adding small and incremental changes to the default Symfony Standard edition until you can reproduce the bug.