Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Improve error message when ext-xml is not installed #1099

Closed
wants to merge 1 commit into from

Conversation

alexcarol
Copy link

@alexcarol alexcarol commented Jul 4, 2017

Ran into this with a fresh installation of php from ondrej ppa on debian and the standard edition.

When I ran this composer install I got the following output:

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DOMDocument" from the global namespace.
Did you forget a "use" statement? in /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.php:52
Stack trace:
#0 /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php(368): Symfony\Component\Config\Util\XmlUtils::loadFile('/home/alex/repo...', Array)
#1 /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php(41): Symfony\Component\DependencyInjection\Loader\XmlFileLoader->parseFileToDOM('/home/alex/repo...')
#2 /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php(96): Symfony\Component\DependencyInjection\Loader\XmlFileLoader->load('web.xml')
#3 /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfig in /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.php on line 52
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception

                                                                                                                                                                                             
  [RuntimeException]                                                                                                                                                                         
  An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                                                  
  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DOMDocument" from the global namespace.                                      
  Did you forget a "use" statement? in /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.php:52                                                       
  Stack trace:                                                                                                                                                                               
  #0 /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php(368): Symfony\Component\Config\Util\XmlUtils::loadFile('/home/alex/re  
  po...', Array)                                                                                                                                                                             
  #1 /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php(41): Symfony\Component\DependencyInjection\Loader\XmlFileLoader->pars  
  eFileToDOM('/home/alex/repo...')                                                                                                                                                           
  #2 /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php(96): Symfony\Component\DependencyInjection\Loader\XmlFileL  
  oader->load('web.xml')                                                                                                                                                                     
  #3 /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfig in /home/alex/repos/dummy/vendor/symfony/symfony/src/Symfony/Com  
  ponent/Config/Util/XmlUtils.php on line 52                                                                                                                                                 
                                                                                                                                                                                             

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...

Now it's changed to this, which should make the experience less painful to anyone getting started with symfony or php:

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-xml * is missing from your system. Install or enable PHP's xml extension.

@Pierstoval
Copy link
Contributor

Actually this requirement should be present in the Symfony components that need it, not in the Standard Edition

@alexcarol
Copy link
Author

The fail comes from XmlFileLoader in symfony/dependency-injection, which is using XmlUtils from symfony/config. I'm not sure it makes sense for those components to require php-xml, as they're optional (in the same way that symfony/dependency-injection doesn't make it compulsory to have symfony/yaml).

As it is not a hard symfony requirement (but is a requirement for the standard edition to work) I think it should be added here.

@Tobion
Copy link
Contributor

Tobion commented Jul 5, 2017

symfony/framework-bundle already requires it since symfony/symfony#22676
I guess it should by extension also be required by symfony/symfony and the other bundles as @xabbuh also said.

@fabpot
Copy link
Member

fabpot commented Jul 6, 2017

agreed, so closing this one here.

@fabpot fabpot closed this Jul 6, 2017
@alexcarol alexcarol deleted the improvement/errorMessage branch July 6, 2017 06:04
fabpot added a commit to symfony/symfony that referenced this pull request Jul 6, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

require the XML PHP extension

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22676 (comment), symfony/symfony-standard#1099
| License       | MIT
| Doc PR        |

I suggest to either revert #22676 or to be consistent and require the XML extension in all bundles as well as in the `symfony/symfony` package.

Commits
-------

032e654 require the XML PHP extension
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants