Skip to content

[Form][DX] Enabling the form component without having it installed does not fail #25093

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

Closed
derrabus opened this issue Nov 21, 2017 · 0 comments
Closed
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) Form FrameworkBundle

Comments

@derrabus
Copy link
Member

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 4.0.0-RC1

Reproducer: https://github.com/derrabus/symfony-reproducers/tree/bug/no-exception-on-missing-form-component

It is possible to enable the form component without having it actually installed. Container compilation will work without errors and the application remains usable. However, if the console is called without a command, it will bail because of a missing class.

$ ./bin/console
Symfony 4.0.0-RC1 (kernel: src, env: dev, debug: true)

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -e, --env=ENV         The environment name [default: "dev"]
      --no-debug        Switches off debug mode
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

2017-11-21T22:58:12+00:00 [error] An error occurred while using the console. Message: "Class 'Symfony\Component\Form\Command\DebugCommand' not found"
2017-11-21T22:58:12+00:00 [critical] Class 'Symfony\Component\Form\Command\DebugCommand' not found

In getConsole_Command_FormDebugService.php line 8:

  Attempted to load class "DebugCommand" from namespace "Symfony\Component\Form\Command".
  Did you forget a "use" statement for "Symfony\Bridge\Twig\Command\DebugCommand"?


list [--raw] [--format FORMAT] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] [<command>] [<namespace>]

Also, installing Twig will break the container compilation:

$ composer require twig
Using version ^4.0@RC for symfony/twig-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Installing twig/twig (v2.4.4): Loading from cache
  - Installing symfony/twig-bridge (v4.0.0-RC1): Loading from cache
  - Installing symfony/twig-bundle (v4.0.0-RC1): Loading from cache
Writing lock file
Generating autoload files
Symfony operations: 1 recipe (2b3a73184b0320a68c669f39ebe1b621)
  - Configuring symfony/twig-bundle (3.3): From github.com/symfony/recipes:master
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!
!!  In ContainerBuilder.php line 942:
!!
!!    You have requested a non-existent service "twig.extension.form".
!!
!!
!!

Installation failed, reverting ./composer.json to its original content.

Both error messages are imho not helpful. I would expect a nice exception if the Form component is enabled without having it installed, e.g. "Form cannot be enabled. Please install symfony/form first."

@derrabus derrabus changed the title [Form][DX] Enabling the form component with having it installed does not fail [Form][DX] Enabling the form component without having it installed does not fail Nov 21, 2017
@xabbuh xabbuh added DX DX = Developer eXperience (anything that improves the experience of using Symfony) Form FrameworkBundle labels Nov 22, 2017
nicolas-grekas added a commit that referenced this issue Nov 22, 2017
…nabled component is missing (derrabus)

This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle][DX] Display a nice error message if an enabled component is missing

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25093
| License       | MIT
| Doc PR        | N/A

Commits
-------

2b45805 Display a nice error message if the form/serializer component is missing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) Form FrameworkBundle
Projects
None yet
Development

No branches or pull requests

3 participants