diff --git a/UPGRADE-3.2.md b/UPGRADE-3.2.md
index 1a78140437..f90b5c885a 100644
--- a/UPGRADE-3.2.md
+++ b/UPGRADE-3.2.md
@@ -4,6 +4,8 @@ UPGRADE FROM 3.1 to 3.2
FrameworkBundle
---------------
+ * The `doctrine/annotations` dependency has been removed; require it via `composer
+ require doctrine/annotations` if you are using annotations in your project
* The `symfony/security-core` and `symfony/security-csrf` dependencies have
been removed; require them via `composer require symfony/security-core
symfony/security-csrf` if you depend on them and don't already depend on
diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
index 9bfe46b8f9..6d3a5b3e09 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
@@ -4,6 +4,7 @@ CHANGELOG
3.2.0
-----
+ * Removed `doctrine/annotations` from the list of required dependencies in `composer.json`
* Removed `symfony/security-core` and `symfony/security-csrf` from the list of required dependencies in `composer.json`
* Removed `symfony/templating` from the list of required dependencies in `composer.json`
* Removed `symfony/translation` from the list of required dependencies in `composer.json`
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index 27e3dd8881..c17822a3bf 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -593,7 +593,7 @@ class Configuration implements ConfigurationInterface
->children()
->arrayNode('annotations')
->info('annotation configuration')
- ->addDefaultsIfNotSet()
+ ->canBeDisabled()
->children()
->scalarNode('cache')->defaultValue('php_array')->end()
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 1d602ac9c2..c318b011c0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -48,6 +48,7 @@ class FrameworkExtension extends Extension
private $formConfigEnabled = false;
private $translationConfigEnabled = false;
private $sessionConfigEnabled = false;
+ private $annotationsConfigEnabled = false;
/**
* @var string|null
@@ -79,6 +80,8 @@ class FrameworkExtension extends Extension
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
+ $this->annotationsConfigEnabled = $this->isConfigEnabled($container, $config['annotations']);
+
// A translator must always be registered (as support is included by
// default in the Form component). If disabled, an identity translator
// will be used and everything will still work as expected.
@@ -891,6 +894,10 @@ class FrameworkExtension extends Extension
$definition->replaceArgument(0, $config['strict_email']);
if (array_key_exists('enable_annotations', $config) && $config['enable_annotations']) {
+ if (!$this->annotationsConfigEnabled) {
+ throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
+ }
+
$validatorBuilder->addMethodCall('enableAnnotationMapping', array(new Reference('annotation_reader')));
}
@@ -956,6 +963,14 @@ class FrameworkExtension extends Extension
private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, $loader)
{
+ if (!$this->annotationsConfigEnabled) {
+ return;
+ }
+
+ if (!class_exists('Doctrine\Common\Annotations\Annotation')) {
+ throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
+ }
+
$loader->load('annotations.xml');
if ('none' !== $config['cache']) {
@@ -1080,6 +1095,10 @@ class FrameworkExtension extends Extension
$serializerLoaders = array();
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
+ if (!$this->annotationsConfigEnabled) {
+ throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
+ }
+
$annotationLoader = new Definition(
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
array(new Reference('annotation_reader'))
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
index f78174961c..804072e07d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
@@ -188,6 +188,7 @@
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
index 71acb1bca2..f07f5261bb 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
@@ -25,7 +25,6 @@
- Doctrine\Common\Annotations\AnnotationRegistry
Symfony\Component\HttpFoundation\ParameterBag
Symfony\Component\HttpFoundation\HeaderBag
Symfony\Component\HttpFoundation\FileBag
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
index b7bd64a6e3..adfc46d14f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
@@ -216,6 +216,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
'cache' => 'php_array',
'file_cache_dir' => '%kernel.cache_dir%/annotations',
'debug' => true,
+ 'enabled' => true,
),
'serializer' => array(
'enabled' => false,
diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json
index 602e723e78..19affe7c64 100644
--- a/src/Symfony/Bundle/FrameworkBundle/composer.json
+++ b/src/Symfony/Bundle/FrameworkBundle/composer.json
@@ -29,8 +29,7 @@
"symfony/finder": "~2.8|~3.0",
"symfony/routing": "~3.0",
"symfony/stopwatch": "~2.8|~3.0",
- "doctrine/cache": "~1.0",
- "doctrine/annotations": "~1.0"
+ "doctrine/cache": "~1.0"
},
"require-dev": {
"symfony/asset": "~2.8|~3.0",
@@ -51,6 +50,7 @@
"symfony/validator": "~3.2",
"symfony/yaml": "~3.2",
"symfony/property-info": "~2.8|~3.0",
+ "doctrine/annotations": "~1.0",
"phpdocumentor/reflection-docblock": "^3.0",
"twig/twig": "~1.23|~2.0"
},
diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json
index 7e4d1f2154..3ee1325ea2 100644
--- a/src/Symfony/Bundle/SecurityBundle/composer.json
+++ b/src/Symfony/Bundle/SecurityBundle/composer.json
@@ -22,6 +22,7 @@
"symfony/polyfill-php70": "~1.0"
},
"require-dev": {
+ "symfony/asset": "~2.8|~3.0",
"symfony/browser-kit": "~2.8|~3.0",
"symfony/console": "~2.8|~3.0",
"symfony/css-selector": "~2.8|~3.0",