Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by
  1. Home
  2. Documentation
  3. Contributing
  4. Code
  5. Creating a Bug Reproducer

Creating a Bug Reproducer

Edit this page

The main Symfony code repository receives thousands of issues reports per year. Some of those issues are easy to understand and can be fixed without any other information. However, other issues are much harder to understand because developers can't 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.

Reproducing Simple Bugs

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:
<?php
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));

Reproducing Complex Bugs

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 creating a new project. To do so:

  1. Create a new project:
1
$ composer create-project symfony/skeleton bug_app
  1. Add and commit the changes generated by Symfony.
  2. 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.
  3. Add and commit your changes.
  4. Create a new repository on GitHub (give it any name).
  5. Follow the instructions on GitHub to add the origin remote to your local project and push it.
  6. Add a comment in your original issue report to share the URL of your forked project (e.g. https://github.com/YOUR-GITHUB-USERNAME/symfony_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.)

Adding the Minimum Amount of Code Possible

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 creating your project:

  1. Don't edit any of the default Symfony configuration options.
  2. Don't copy your original application code and don't use the same structure of controllers, actions, etc. as in your original application.
  3. Create a small controller and add your routing definition that shows the bug.
  4. Don't create or modify any other file.
  5. Install the local web server provided by Symfony and use the symfony server:start command to browse to the new route and see if the bug appears or not.
  6. If you can see the bug, you're done and you can already share the code with us.
  7. 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 and define the route using XML instead. Or maybe your application registers some event listeners and that's where the real bug is. In that case, add an event listener that's similar to your real app to see if you can find the bug.

In short, the idea is to keep adding small and incremental changes to a new project until you can reproduce the bug.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version

    Symfony 7.1 is backed by

    Show your Sylius expertise

    Show your Sylius expertise

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Version:

    Table of Contents

    • Reproducing Simple Bugs
    • Reproducing Complex Bugs
      • Adding the Minimum Amount of Code Possible

    Symfony footer

    Avatar of Susheel Thapa, a Symfony contributor

    Thanks Susheel Thapa for being a Symfony contributor

    1 commit • 14 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • What is Symfony?
      • Symfony at a Glance
      • Symfony Components
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • Symfony Community
      • SymfonyConnect
      • Events & Meetups
      • Projects using Symfony
      • Contributors
      • Symfony Jobs
      • Backers
      • Code of Conduct
      • Downloads Stats
      • Support
    • Blog

      • All Blog Posts
      • A Week of Symfony
      • Case Studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Living on the edge
      • Releases
      • Security Advisories
      • Symfony Insight
      • Twig
      • SensioLabs Blog
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Powered by

    Follow Symfony