diff --git a/_build/redirection_map b/_build/redirection_map index 146e731e460..1e0245956ea 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -291,10 +291,18 @@ /components/browser_kit/introduction /components/browser_kit /components/class_loader/introduction /components/class_loader /components/class_loader/index /components/class_loader +/components/class_loader/cache_class_loader /components/class_loader +/components/class_loader/class_loader /components/class_loader +/components/class_loader/class_map_generator /components/class_loader +/components/class_loader/debug_class_loader /components/class_loader +/components/class_loader/map_class_loader /components/class_loader +/components/class_loader/map_class_loader /components/class_loader +/components/class_loader/psr4_class_loader /components/class_loader /components/config/introduction /components/config /components/config/index /components/config /components/console/helpers/tablehelper /components/console/helpers/table /components/console/helpers/progresshelper /components/console/helpers/progressbar +/components/console/helpers/dialoghelper /components/console/helpers/questionhelper /components/console/introduction /components/console /components/console/index /components/console /components/debug/class_loader /components/debug diff --git a/components/class_loader.rst b/components/class_loader.rst index 74c275a055a..f3268b1ca71 100644 --- a/components/class_loader.rst +++ b/components/class_loader.rst @@ -4,72 +4,9 @@ The ClassLoader Component ========================= - The ClassLoader component provides tools to autoload your classes and - cache their locations for performance. - .. caution:: - The ClassLoader component was deprecated in Symfony 3.3 and it will be - removed in 4.0. As an alternative, use any of the `class loading optimizations`_ - provided by Composer. - -Usage ------ - -Whenever you reference a class that has not been required or included yet, -PHP uses the `autoloading mechanism`_ to delegate the loading of a file -defining the class. Symfony provides three autoloaders, which are able to -load your classes: - -* :doc:`/components/class_loader/class_loader`: loads classes that follow - the `PSR-0`_ class naming standard; - -* :doc:`/components/class_loader/psr4_class_loader`: loads classes that follow - the `PSR-4`_ class naming standard; - -* :doc:`/components/class_loader/map_class_loader`: loads classes using - a static map from class name to file path. - -Additionally, the Symfony ClassLoader component ships with a wrapper class -which makes it possible -:doc:`to cache the results of a class loader `. - -When using the :doc:`Debug component `, you -can also use a special :ref:`DebugClassLoader ` -that eases debugging by throwing more helpful exceptions when a class could -not be found by a class loader. - -Installation ------------- - -You can install the component in 2 different ways: - -* :doc:`Install it via Composer ` (``symfony/class-loader`` - on `Packagist`_); -* Use the official Git repository (https://github.com/symfony/class-loader). - -.. include:: /components/require_autoload.rst.inc - -Learn More ----------- - -.. toctree:: - :glob: - :maxdepth: 1 - - class_loader/class_loader - class_loader/class_map_generator.rst - class_loader/debug_class_loader.rst - class_loader/map_class_loader.rst - class_loader/psr4_class_loader.rst - -.. toctree:: - :hidden: - - class_loader/cache_class_loader + The ClassLoader component was removed in Symfony 4.0. As an alternative, use + any of the `class loading optimizations`_ provided by Composer. -.. _PSR-0: http://www.php-fig.org/psr/psr-0/ -.. _PSR-4: http://www.php-fig.org/psr/psr-4/ -.. _`autoloading mechanism`: http://php.net/manual/en/language.oop5.autoload.php -.. _Packagist: https://packagist.org/packages/symfony/class-loader .. _`class loading optimizations`: https://getcomposer.org/doc/articles/autoloader-optimization.md diff --git a/components/class_loader/cache_class_loader.rst b/components/class_loader/cache_class_loader.rst deleted file mode 100644 index a75f743826c..00000000000 --- a/components/class_loader/cache_class_loader.rst +++ /dev/null @@ -1,15 +0,0 @@ -.. index:: - single: APC; ApcClassLoader - single: ClassLoader; ApcClassLoader - single: ClassLoader; Cache - single: ClassLoader; XcacheClassLoader - single: XCache; XcacheClassLoader - -Cache a Class Loader -==================== - -The ``ApcClassLoader``, the ``WinCacheClassLoader`` and the ``XcacheClassLoader`` -are deprecated since Symfony 3.3. As an alternative, use any of the -`class loading optimizations`_ provided by Composer. - -.. _`class loading optimizations`: https://getcomposer.org/doc/articles/autoloader-optimization.md diff --git a/components/class_loader/class_loader.rst b/components/class_loader/class_loader.rst deleted file mode 100644 index adf9b6e52b2..00000000000 --- a/components/class_loader/class_loader.rst +++ /dev/null @@ -1,75 +0,0 @@ -.. index:: - single: ClassLoader; PSR-0 Class Loader - -The PSR-0 Class Loader -====================== - -If your classes and third-party libraries follow the `PSR-0`_ standard, -you can use the :class:`Symfony\\Component\\ClassLoader\\ClassLoader` class -to load all of your project's classes. - -.. tip:: - - You can use both the ``ApcClassLoader`` and the ``XcacheClassLoader`` - to :doc:`cache ` a ``ClassLoader`` - instance. - -Usage ------ - -Registering the :class:`Symfony\\Component\\ClassLoader\\ClassLoader` autoloader -is straightforward:: - - require_once '/path/to/src/Symfony/Component/ClassLoader/ClassLoader.php'; - - use Symfony\Component\ClassLoader\ClassLoader; - - $loader = new ClassLoader(); - - // to enable searching the include path (eg. for PEAR packages) - $loader->setUseIncludePath(true); - - // ... register namespaces and prefixes here - see below - - $loader->register(); - -Use :method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefix` or -:method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefixes` to register -your classes:: - - // register a single namespaces - $loader->addPrefix('Symfony', __DIR__.'/vendor/symfony/symfony/src'); - - // register several namespaces at once - $loader->addPrefixes(array( - 'Symfony' => __DIR__.'/../vendor/symfony/symfony/src', - 'Monolog' => __DIR__.'/../vendor/monolog/monolog/src', - )); - - // register a prefix for a class following the PEAR naming conventions - $loader->addPrefix('Twig_', __DIR__.'/vendor/twig/twig/lib'); - - $loader->addPrefixes(array( - 'Swift_' => __DIR__.'/vendor/swiftmailer/swiftmailer/lib/classes', - 'Twig_' => __DIR__.'/vendor/twig/twig/lib', - )); - -Classes from a sub-namespace or a sub-hierarchy of `PEAR`_ classes can be -looked for in a location list to ease the vendoring of a sub-set of classes -for large projects:: - - $loader->addPrefixes(array( - 'Doctrine\Common' => __DIR__.'/vendor/doctrine/common/lib', - 'Doctrine\DBAL\Migrations' => __DIR__.'/vendor/doctrine/migrations/lib', - 'Doctrine\DBAL' => __DIR__.'/vendor/doctrine/dbal/lib', - 'Doctrine' => __DIR__.'/vendor/doctrine/orm/lib', - )); - -In this example, if you try to use a class in the ``Doctrine\Common`` namespace -or one of its children, the autoloader will first look for the class under -the ``doctrine-common`` directory. If not found, it will then fallback to -the default ``Doctrine`` directory (the last one configured) before giving -up. The order of the prefix registrations is significant in this case. - -.. _PEAR: http://pear.php.net/manual/en/standards.naming.php -.. _PSR-0: http://www.php-fig.org/psr/psr-0/ diff --git a/components/class_loader/class_map_generator.rst b/components/class_loader/class_map_generator.rst deleted file mode 100644 index da1a9c73ab4..00000000000 --- a/components/class_loader/class_map_generator.rst +++ /dev/null @@ -1,128 +0,0 @@ -.. index:: - single: Autoloading; Class Map Generator - single: ClassLoader; Class Map Generator - -The Class Map Generator -======================= - -Loading a class usually is an easy task given the `PSR-0`_ and `PSR-4`_ -standards. Thanks to the Symfony ClassLoader component or the autoloading -mechanism provided by Composer, you don't have to map your class names to -actual PHP files manually. Nowadays, PHP libraries usually come with autoloading -support through Composer. - -But from time to time you may have to use a third-party library that comes -without any autoloading support and therefore forces you to load each class -manually. For example, imagine a library with the following directory structure: - -.. code-block:: text - - library/ - ├── bar/ - │   ├── baz/ - │   │   └── Boo.php - │   └── Foo.php - └── foo/ - ├── bar/ - │   └── Foo.php - └── Bar.php - -These files contain the following classes: - -=========================== ================ -File Class Name -=========================== ================ -``library/bar/baz/Boo.php`` ``Acme\Bar\Baz`` -``library/bar/Foo.php`` ``Acme\Bar`` -``library/foo/bar/Foo.php`` ``Acme\Foo\Bar`` -``library/foo/Bar.php`` ``Acme\Foo`` -=========================== ================ - -To make your life easier, the ClassLoader component comes with a -:class:`Symfony\\Component\\ClassLoader\\ClassMapGenerator` class that makes -it possible to create a map of class names to files. - -Generating a Class Map ----------------------- - -To generate the class map, simply pass the root directory of your class -files to the -:method:`Symfony\\Component\\ClassLoader\\ClassMapGenerator::createMap` -method:: - - use Symfony\Component\ClassLoader\ClassMapGenerator; - - var_dump(ClassMapGenerator::createMap(__DIR__.'/library')); - -Given the files and class from the table above, you should see an output -like this: - -.. code-block:: text - - Array - ( - [Acme\Foo] => /var/www/library/foo/Bar.php - [Acme\Foo\Bar] => /var/www/library/foo/bar/Foo.php - [Acme\Bar\Baz] => /var/www/library/bar/baz/Boo.php - [Acme\Bar] => /var/www/library/bar/Foo.php - ) - -Dumping the Class Map ---------------------- - -Writing the class map to the console output is not really sufficient when -it comes to autoloading. Luckily, the ``ClassMapGenerator`` provides the -:method:`Symfony\\Component\\ClassLoader\\ClassMapGenerator::dump` method -to save the generated class map to the filesystem:: - - use Symfony\Component\ClassLoader\ClassMapGenerator; - - ClassMapGenerator::dump(__DIR__.'/library', __DIR__.'/class_map.php'); - -This call to ``dump()`` generates the class map and writes it to the ``class_map.php`` -file in the same directory with the following contents:: - - '/var/www/library/foo/Bar.php', - 'Acme\\Foo\\Bar' => '/var/www/library/foo/bar/Foo.php', - 'Acme\\Bar\\Baz' => '/var/www/library/bar/baz/Boo.php', - 'Acme\\Bar' => '/var/www/library/bar/Foo.php', - ); - -Instead of loading each file manually, you'll only have to register the -generated class map with, for example, the -:class:`Symfony\\Component\\ClassLoader\\MapClassLoader`:: - - use Symfony\Component\ClassLoader\MapClassLoader; - - $mapping = include __DIR__.'/class_map.php'; - $loader = new MapClassLoader($mapping); - $loader->register(); - - // you can now use the classes: - use Acme\Foo; - - $foo = new Foo(); - - // ... - -.. note:: - - The example assumes that you already have autoloading working (e.g. - through `Composer`_ or one of the other class loaders from the ClassLoader - component. - -Besides dumping the class map for one directory, you can also pass an array -of directories for which to generate the class map (the result actually -is the same as in the example above):: - - use Symfony\Component\ClassLoader\ClassMapGenerator; - - ClassMapGenerator::dump( - array(__DIR__.'/library/bar', __DIR__.'/library/foo'), - __DIR__.'/class_map.php' - ); - -.. _`PSR-0`: http://www.php-fig.org/psr/psr-0 -.. _`PSR-4`: http://www.php-fig.org/psr/psr-4 -.. _`Composer`: https://getcomposer.org diff --git a/components/class_loader/debug_class_loader.rst b/components/class_loader/debug_class_loader.rst deleted file mode 100644 index 1bd3446af27..00000000000 --- a/components/class_loader/debug_class_loader.rst +++ /dev/null @@ -1,8 +0,0 @@ -Debugging a Class Loader -======================== - -.. caution:: - - The ``DebugClassLoader`` from the ClassLoader component was deprecated - in Symfony 2.5 and removed in Symfony 3.0. Use the - :ref:`DebugClassLoader provided by the Debug component `. diff --git a/components/class_loader/map_class_loader.rst b/components/class_loader/map_class_loader.rst deleted file mode 100644 index f9bd70abfa4..00000000000 --- a/components/class_loader/map_class_loader.rst +++ /dev/null @@ -1,41 +0,0 @@ -.. index:: - single: ClassLoader; MapClassLoader - -MapClassLoader -============== - -The :class:`Symfony\\Component\\ClassLoader\\MapClassLoader` allows you -to autoload files via a static map from classes to files. This is useful -if you use third-party libraries which don't follow the `PSR-0`_ standards -and so can't use the -:doc:`PSR-0 class loader `. - -The ``MapClassLoader`` can be used along with the -:doc:`PSR-0 class loader ` by -configuring and calling the ``register()`` method on both. - -.. note:: - - The default behavior is to append the ``MapClassLoader`` on the autoload - stack. If you want to use it as the first autoloader, pass ``true`` - when calling the ``register()`` method. Your class loader will then - be prepended on the autoload stack. - -Usage ------ - -Using it is as easy as passing your mapping to its constructor when creating -an instance of the ``MapClassLoader`` class:: - - require_once '/path/to/src/Symfony/Component/ClassLoader/MapClassLoader.php'; - - $mapping = array( - 'Foo' => '/path/to/Foo', - 'Bar' => '/path/to/Bar', - ); - - $loader = new MapClassLoader($mapping); - - $loader->register(); - -.. _PSR-0: http://www.php-fig.org/psr/psr-0/ diff --git a/components/class_loader/psr4_class_loader.rst b/components/class_loader/psr4_class_loader.rst deleted file mode 100644 index dc66614892b..00000000000 --- a/components/class_loader/psr4_class_loader.rst +++ /dev/null @@ -1,61 +0,0 @@ -.. index:: - single: ClassLoader; PSR-4 Class Loader - -The PSR-4 Class Loader -====================== - -Libraries that follow the `PSR-4`_ standard can be loaded with the ``Psr4ClassLoader``. - -.. note:: - - If you manage your dependencies via Composer, you get a PSR-4 compatible - autoloader out of the box. Use this loader in environments where Composer - is not available. - -.. tip:: - - All Symfony components follow PSR-4. - -Usage ------ - -The following example demonstrates how you can use the -:class:`Symfony\\Component\\ClassLoader\\Psr4ClassLoader` autoloader to use -Symfony's Yaml component. Imagine, you downloaded both the ClassLoader and -Yaml component as ZIP packages and unpacked them to a ``libs`` directory. -The directory structure will look like this: - -.. code-block:: text - - libs/ - ClassLoader/ - Psr4ClassLoader.php - ... - Yaml/ - Yaml.php - ... - config.yml - demo.php - -In ``demo.php`` you are going to parse the ``config.yml`` file. To do that, you -first need to configure the ``Psr4ClassLoader``:: - - use Symfony\Component\ClassLoader\Psr4ClassLoader; - use Symfony\Component\Yaml\Yaml; - - require __DIR__.'/lib/ClassLoader/Psr4ClassLoader.php'; - - $loader = new Psr4ClassLoader(); - $loader->addPrefix('Symfony\Component\Yaml\\', __DIR__.'/lib/Yaml'); - $loader->register(); - - $data = Yaml::parse(file_get_contents(__DIR__.'/config.yml')); - -First of all, the class loader is loaded manually using a ``require`` -statement, since there is no autoload mechanism yet. With the -:method:`Symfony\\Component\\ClassLoader\\Psr4ClassLoader::addPrefix` call, you -tell the class loader where to look for classes with the -``Symfony\Component\Yaml\`` namespace prefix. After registering the autoloader, -the Yaml component is ready to be used. - -.. _PSR-4: http://www.php-fig.org/psr/psr-4/ diff --git a/components/config/caching.rst b/components/config/caching.rst index 99cd4f6a2b1..7881306a4b8 100644 --- a/components/config/caching.rst +++ b/components/config/caching.rst @@ -32,7 +32,7 @@ should be regenerated:: $userMatcherCache = new ConfigCache($cachePath, true); if (!$userMatcherCache->isFresh()) { - // fill this with an array of 'users.yml' file paths + // fill this with an array of 'users.yaml' file paths $yamlUserFiles = ...; $resources = array(); diff --git a/components/config/definition.rst b/components/config/definition.rst index 43025d3178d..d3346a5f9fc 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -804,10 +804,10 @@ Otherwise the result is a clean array of configuration values:: use Acme\DatabaseConfiguration; $config1 = Yaml::parse( - file_get_contents(__DIR__.'/src/Matthias/config/config.yml') + file_get_contents(__DIR__.'/src/Matthias/config/config.yaml') ); $config2 = Yaml::parse( - file_get_contents(__DIR__.'/src/Matthias/config/config_extra.yml') + file_get_contents(__DIR__.'/src/Matthias/config/config_extra.yaml') ); $configs = array($config1, $config2); diff --git a/components/config/resources.rst b/components/config/resources.rst index de88b483b42..b1ea7b2c269 100644 --- a/components/config/resources.rst +++ b/components/config/resources.rst @@ -19,10 +19,10 @@ files. This can be done with the :class:`Symfony\\Component\\Config\\FileLocator use Symfony\Component\Config\FileLocator; - $configDirectories = array(__DIR__.'/app/config'); + $configDirectories = array(__DIR__.'/config'); $locator = new FileLocator($configDirectories); - $yamlUserFiles = $locator->locate('users.yml', null, false); + $yamlUserFiles = $locator->locate('users.yaml', null, false); The locator receives a collection of locations where it should look for files. The first argument of ``locate()`` is the name of the file to look @@ -53,12 +53,12 @@ which allows for recursively importing other resources:: // maybe import some other resource: - // $this->import('extra_users.yml'); + // $this->import('extra_users.yaml'); } public function supports($resource, $type = null) { - return is_string($resource) && 'yml' === pathinfo( + return is_string($resource) && 'yaml' === pathinfo( $resource, PATHINFO_EXTENSION ); @@ -88,5 +88,5 @@ the resource:: $delegatingLoader = new DelegatingLoader($loaderResolver); // YamlUserLoader is used to load this resource because it supports - // files with the '.yml' extension - $delegatingLoader->load(__DIR__.'/users.yml'); + // files with the '.yaml' extension + $delegatingLoader->load(__DIR__.'/users.yaml'); diff --git a/components/console/helpers/dialoghelper.rst b/components/console/helpers/dialoghelper.rst deleted file mode 100644 index 8618ffcba17..00000000000 --- a/components/console/helpers/dialoghelper.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. index:: - single: Console Helpers; Dialog Helper - -Dialog Helper -============= - -.. caution:: - - The Dialog Helper was deprecated in Symfony 2.5 and removed in - Symfony 3.0. You should now use the - :doc:`Question Helper ` instead, - which is simpler to use. diff --git a/components/console/helpers/index.rst b/components/console/helpers/index.rst index 38a8c2a7939..87c62ca7629 100644 --- a/components/console/helpers/index.rst +++ b/components/console/helpers/index.rst @@ -7,7 +7,6 @@ The Console Helpers .. toctree:: :hidden: - dialoghelper formatterhelper processhelper progressbar diff --git a/components/dependency_injection/_imports-parameters-note.rst.inc b/components/dependency_injection/_imports-parameters-note.rst.inc index 3b479e70ba6..eb68a4dbdcc 100644 --- a/components/dependency_injection/_imports-parameters-note.rst.inc +++ b/components/dependency_injection/_imports-parameters-note.rst.inc @@ -8,13 +8,13 @@ .. code-block:: yaml - # app/config/config.yml + # config/services.yaml imports: - - { resource: '%kernel.project_dir%/somefile.yml' } + - { resource: '%kernel.project_dir%/somefile.yaml' } .. code-block:: xml - + - + .. code-block:: php - // app/config/config.php - $loader->import('%kernel.project_dir%/somefile.yml'); + // config/services.php + $loader->import('%kernel.project_dir%/somefile.yaml'); diff --git a/components/dependency_injection/compilation.rst b/components/dependency_injection/compilation.rst index d2b494ab4ca..38ca077f743 100644 --- a/components/dependency_injection/compilation.rst +++ b/components/dependency_injection/compilation.rst @@ -121,7 +121,7 @@ are loaded:: $container->registerExtension(new AcmeDemoExtension); $loader = new YamlFileLoader($container, new FileLocator(__DIR__)); - $loader->load('config.yml'); + $loader->load('config.yaml'); // ... $container->compile(); diff --git a/components/dependency_injection/workflow.rst b/components/dependency_injection/workflow.rst index 5ad8ae7c3d8..750420f4d47 100644 --- a/components/dependency_injection/workflow.rst +++ b/components/dependency_injection/workflow.rst @@ -34,7 +34,7 @@ for more details. Application-level Configuration ------------------------------- -Application level config is loaded from the ``app/config`` directory. Multiple +Application level config is loaded from the ``config`` directory. Multiple files are loaded which are then merged when the extensions are processed. This allows for different configuration for different environments e.g. dev, prod. diff --git a/components/filesystem.rst b/components/filesystem.rst index 0cc1c20669d..e825df024f2 100644 --- a/components/filesystem.rst +++ b/components/filesystem.rst @@ -314,14 +314,5 @@ Whenever something wrong happens, an exception implementing An :class:`Symfony\\Component\\Filesystem\\Exception\\IOException` is thrown if directory creation fails. -Learn More ----------- - -.. toctree:: - :maxdepth: 1 - :glob: - - filesystem/* - .. _`Packagist`: https://packagist.org/packages/symfony/filesystem .. _`umask`: https://en.wikipedia.org/wiki/Umask diff --git a/components/filesystem/lock_handler.rst b/components/filesystem/lock_handler.rst index 3c2e7ce3b77..45ea7cda95c 100644 --- a/components/filesystem/lock_handler.rst +++ b/components/filesystem/lock_handler.rst @@ -1,92 +1,9 @@ +:orphan: + LockHandler =========== -What is a Lock? ---------------- - -File locking is a mechanism that restricts access to a computer file by allowing -only one user or process access at any specific time. This mechanism was -introduced a few decades ago for mainframes, but continues being useful for -modern applications. - -Symfony provides a LockHelper to help you use locks in your project. - -Usage ------ - -.. caution:: - - The lock handler only works if you're using just one server. If you have - several hosts, you must not use this helper. - -A lock can be used, for example, to allow only one instance of a command to run. - -.. code-block:: php - - use Symfony\Component\Filesystem\LockHandler; - - $lockHandler = new LockHandler('hello.lock'); - if (!$lockHandler->lock()) { - // the resource "hello" is already locked by another process - - return 0; - } - -The first argument of the constructor is a string that it will use as part of -the name of the file used to create the lock on the local filesystem. A best -practice for Symfony commands is to use the command name, such as ``acme:my-command``. -``LockHandler`` sanitizes the contents of the string before creating -the file, so you can pass any value for this argument. - -.. tip:: - - The ``.lock`` extension is optional, but it's a common practice to include - it. This will make it easier to find lock files on the filesystem. Moreover, - to avoid name collisions, ``LockHandler`` also appends a hash to the name of - the lock file. - -By default, the lock will be created in the system's temporary directory, but -you can optionally select the directory where locks are created by passing it as -the second argument of the constructor. - -.. tip:: - - Another way to configure the directory where the locks are created is to - define a special environment variable, because PHP will use that value to - override the default temporary directory. On Unix-based systems, define the - ``TMPDIR`` variable. On Windows systems, define any of these variables: - ``TMP``, ``TEMP`` or ``USERPROFILE`` (they are checked in this order). This - technique is useful for example when deploying a third-party Symfony - application whose code can't be modified. - -The :method:`Symfony\\Component\\Filesystem\\LockHandler::lock` method tries to -acquire the lock. If the lock is acquired, the method returns ``true``, -``false`` otherwise. If the ``lock()`` method is called several times on the same -instance it will always return ``true`` if the lock was acquired on the first -call. - -You can pass an optional blocking argument as the first argument to the -``lock()`` method, which defaults to ``false``. If this is set to ``true``, your -PHP code will wait indefinitely until the lock is released by another process. - .. caution:: - Be aware of the fact that the resource lock is automatically released as soon - as PHP applies the garbage-collection process to the ``LockHandler`` object. - This means that if you refactor the first example shown in this article as - follows:: - - use Symfony\Component\Filesystem\LockHandler; - - if (!(new LockHandler('hello.lock'))->lock()) { - // the resource "hello" is already locked by another process - - return 0; - } - - Now the code won't work as expected because PHP's garbage collection mechanism - removes the reference to the ``LockHandler`` object and thus, the lock is released - just after it's been created. - - Another alternative way to release the lock explicitly when needed is to use the - :method:`Symfony\\Component\\Filesystem\\LockHandler::release` method. + The ``LockHandler`` utility is deprecated since Symfony 3.4. Use the new + Symfony Lock component instead. diff --git a/components/form.rst b/components/form.rst index 1cc82b62997..ac31f2cc164 100644 --- a/components/form.rst +++ b/components/form.rst @@ -398,17 +398,17 @@ is created from the form factory. .. code-block:: php-symfony - // src/Acme/TaskBundle/Controller/DefaultController.php - namespace Acme\TaskBundle\Controller; + // src/Controller/TaskController.php + namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\DateType; - class DefaultController extends Controller + class TaskController extends Controller { - public function newAction(Request $request) + public function new(Request $request) { // createFormBuilder is a shortcut to get the "form factory" // and then call "createBuilder()" on it @@ -418,7 +418,7 @@ is created from the form factory. ->add('dueDate', DateType::class) ->getForm(); - return $this->render('@AcmeTask/Default/new.html.twig', array( + return $this->render('task/new.html.twig', array( 'form' => $form->createView(), )); } @@ -604,16 +604,16 @@ method: .. code-block:: php-symfony - // src/Acme/TaskBundle/Controller/DefaultController.php - namespace Acme\TaskBundle\Controller; + // src/Controller/TaskController.php + namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\TextType; - class DefaultController extends Controller + class TaskController extends Controller { - public function newAction(Request $request) + public function new(Request $request) { $form = $this->createFormBuilder() ->add('task', TextType::class) diff --git a/components/http_foundation/session_configuration.rst b/components/http_foundation/session_configuration.rst index ca5524adbe4..42edb3752c9 100644 --- a/components/http_foundation/session_configuration.rst +++ b/components/http_foundation/session_configuration.rst @@ -147,7 +147,7 @@ configuration: .. code-block:: yaml - # config.yml + # config/packages/framework.yaml framework: session: gc_probability: null diff --git a/components/http_kernel.rst b/components/http_kernel.rst index b72152ec13c..5dea91c8447 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -256,11 +256,11 @@ on the request's information. information is typically placed on the ``Request`` via the ``RouterListener``). This string is then transformed into a PHP callable by doing the following: - a) The ``AcmeDemoBundle:Default:index`` format of the ``_controller`` key - is changed to another string that contains the full class and method - name of the controller by following the convention used in Symfony - e.g. - ``Acme\DemoBundle\Controller\DefaultController::indexAction``. This transformation - is specific to the :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver` + a) If the ``_controller`` key doesn't follow the recommended PHP namespace + format (e.g. ``App\Controller\DefaultController::index``) its format is + transformed into it. For example, the legacy ``AppBundle:Default:index`` + format would be changed to ``Acme\AppBundle\Controller\DefaultController::indexAction``. + This transformation is specific to the :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver` sub-class used by the Symfony Framework. b) A new instance of your controller class is instantiated with no @@ -300,11 +300,10 @@ on the event object that's passed to listeners on this event. the Symfony Framework, and many deal with collecting profiler data when the profiler is enabled. - One interesting listener comes from the `SensioFrameworkExtraBundle`_, - which is packaged with the Symfony Standard Edition. This listener's - `@ParamConverter`_ functionality allows you to pass a full object (e.g. a - ``Post`` object) to your controller instead of a scalar value (e.g. an - ``id`` parameter that was on your route). The listener - + One interesting listener comes from the `SensioFrameworkExtraBundle`_. This + listener's `@ParamConverter`_ functionality allows you to pass a full object + (e.g. a ``Post`` object) to your controller instead of a scalar value (e.g. + an ``id`` parameter that was on your route). The listener - ``ParamConverterListener`` - uses reflection to look at each of the arguments of the controller and tries to use different methods to convert those to objects, which are then stored in the ``attributes`` property of @@ -423,12 +422,11 @@ return a ``Response``. .. sidebar:: ``kernel.view`` in the Symfony Framework There is no default listener inside the Symfony Framework for the ``kernel.view`` - event. However, one core bundle - `SensioFrameworkExtraBundle`_ - *does* - add a listener to this event. If your controller returns an array, - and you place the `@Template`_ annotation above the controller, then this - listener renders a template, passes the array you returned from your - controller to that template, and creates a ``Response`` containing the - returned content from that template. + event. However, `SensioFrameworkExtraBundle`_ *does* add a listener to this + event. If your controller returns an array, and you place the `@Template`_ + annotation above the controller, then this listener renders a template, + passes the array you returned from your controller to that template, and + creates a ``Response`` containing the returned content from that template. Additionally, a popular community bundle `FOSRestBundle`_ implements a listener on this event which aims to give you a robust view layer @@ -514,9 +512,9 @@ as possible to the client (e.g. sending emails). .. sidebar:: ``kernel.terminate`` in the Symfony Framework - If you use the SwiftmailerBundle with Symfony and use ``memory`` spooling, - then the `EmailSenderListener`_ is activated, which actually delivers - any emails that you scheduled to send during the request. + If you use the :ref:`memory spooling ` option of the + default Symfony mailer, then the `EmailSenderListener`_ is activated, which + actually delivers any emails that you scheduled to send during the request. .. _component-http-kernel-kernel-exception: diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 1a62e472b7f..a528ec56f1c 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -134,7 +134,7 @@ message, enclosed with ``/``. For example, with: - + diff --git a/components/property_info.rst b/components/property_info.rst index 8e642a03e31..40f6c667343 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -355,7 +355,7 @@ It can also provide return and scalar types for PHP 7+. .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: property_info: enabled: true diff --git a/components/routing.rst b/components/routing.rst index 4afb1c663c5..089c688469b 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -246,7 +246,7 @@ If you're using the ``YamlFileLoader``, then route definitions look like this: .. code-block:: yaml - # routes.yml + # routes.yaml route1: path: /foo defaults: { _controller: 'MyController::fooAction' } @@ -256,7 +256,7 @@ If you're using the ``YamlFileLoader``, then route definitions look like this: defaults: { _controller: 'MyController::foobarAction' } To load this file, you can use the following code. This assumes that your -``routes.yml`` file is in the same directory as the below code:: +``routes.yaml`` file is in the same directory as the below code:: use Symfony\Component\Config\FileLocator; use Symfony\Component\Routing\Loader\YamlFileLoader; @@ -264,7 +264,7 @@ To load this file, you can use the following code. This assumes that your // look inside *this* directory $locator = new FileLocator(array(__DIR__)); $loader = new YamlFileLoader($locator); - $collection = $loader->load('routes.yml'); + $collection = $loader->load('routes.yaml'); Besides :class:`Symfony\\Component\\Routing\\Loader\\YamlFileLoader` there are two other loaders that work the same way: @@ -337,7 +337,7 @@ automatically in the background if you want to use it. A basic example of the $router = new Router( new YamlFileLoader($locator), - 'routes.yml', + 'routes.yaml', array('cache_dir' => __DIR__.'/cache'), $requestContext ); diff --git a/components/serializer.rst b/components/serializer.rst index 1377ff19bdf..765a0ecd28b 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -21,7 +21,7 @@ the middle. This way, Encoders will only deal with turning specific **formats** into **arrays** and vice versa. The same way, Normalizers will deal with turning specific **objects** into **arrays** and vice versa. -Serialization is a complex topic. This component may not cover all your use cases out of the box, +Serialization is a complex topic. This component may not cover all your use cases out of the box, but it can be useful for developing tools to serialize and deserialize your objects. Installation @@ -243,7 +243,7 @@ like the following:: // For XML // $classMetadataFactory = new ClassMetadataFactory(new XmlFileLoader('/path/to/your/definition.xml')); // For YAML - // $classMetadataFactory = new ClassMetadataFactory(new YamlFileLoader('/path/to/your/definition.yml')); + // $classMetadataFactory = new ClassMetadataFactory(new YamlFileLoader('/path/to/your/definition.yaml')); .. _component-serializer-attributes-groups-annotations: diff --git a/components/translation.rst b/components/translation.rst index dfbf9fd6259..52e70f35008 100644 --- a/components/translation.rst +++ b/components/translation.rst @@ -128,7 +128,7 @@ file as the second argument, instead of an array:: // ... $translator->addLoader('yaml', new YamlFileLoader()); - $translator->addResource('yaml', 'path/to/messages.fr.yml', 'fr_FR'); + $translator->addResource('yaml', 'path/to/messages.fr.yaml', 'fr_FR'); The Translation Process ----------------------- diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst index d5d9ddcd446..3f9997d502d 100644 --- a/components/translation/custom_formats.rst +++ b/components/translation/custom_formats.rst @@ -119,7 +119,7 @@ YAML file are dumped into a text file with the custom format:: use Symfony\Component\Translation\Loader\YamlFileLoader; $loader = new YamlFileLoader(); - $catalogue = $loader->load(__DIR__ . '/translations/messages.fr_FR.yml' , 'fr_FR'); + $catalogue = $loader->load(__DIR__ . '/translations/messages.fr_FR.yaml' , 'fr_FR'); $dumper = new MyFormatDumper(); $dumper->dump($catalogue, array('path' => __DIR__.'/dumps')); diff --git a/components/validator/resources.rst b/components/validator/resources.rst index 7ee7c286f08..c3c2677b99e 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -71,7 +71,7 @@ configure the locations of these files:: use Symfony\Component\Validator\Validation; $validator = Validation::createValidatorBuilder() - ->addYamlMapping('config/validation.yml') + ->addYamlMapping('config/validation.yaml') ->getValidator(); .. note:: @@ -173,13 +173,13 @@ Using a Custom MetadataFactory ------------------------------ All the loaders and the cache are passed to an instance of -:class:`Symfony\\Component\\Validator\\Mapping\\Factory\\LazyLoadingMetadataFactory`. +:class:`Symfony\\Component\\Validator\\Mapping\\Factory\\LazyLoadingMetadataFactory`. This class is responsible for creating a ``ClassMetadata`` instance from all the configured resources. You can also use a custom metadata factory implementation by creating a class which implements -:class:`Symfony\\Component\\Validator\\Mapping\\Factory\\MetadataFactoryInterface`. +:class:`Symfony\\Component\\Validator\\Mapping\\Factory\\MetadataFactoryInterface`. You can set this custom implementation using :method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMetadataFactory`:: diff --git a/components/var_dumper.rst b/components/var_dumper.rst index 98b0a35b68d..c8673d08364 100644 --- a/components/var_dumper.rst +++ b/components/var_dumper.rst @@ -19,8 +19,8 @@ You can install the component in 2 different ways: .. note:: - If using it inside a Symfony application, make sure that the - DebugBundle is enabled in your ``app/AppKernel.php`` file. + If using it inside a Symfony application, make sure that the DebugBundle has + been installed (or run ``composer required debug`` to install it). .. _components-var-dumper-dump: diff --git a/components/yaml.rst b/components/yaml.rst index dbb20fb0a30..af8e1a97833 100644 --- a/components/yaml.rst +++ b/components/yaml.rst @@ -128,7 +128,7 @@ contents of the given file path and converts them to a PHP value:: use Symfony\Component\Yaml\Yaml; - $value = Yaml::parseFile('/path/to/file.yml'); + $value = Yaml::parseFile('/path/to/file.yaml'); If an error occurs during parsing, the parser throws a ``ParseException`` exception. @@ -151,7 +151,7 @@ array to its YAML representation: $yaml = Yaml::dump($array); - file_put_contents('/path/to/file.yml', $yaml); + file_put_contents('/path/to/file.yaml', $yaml); If an error occurs during the dump, the parser throws a :class:`Symfony\\Component\\Yaml\\Exception\\DumpException` exception. @@ -356,20 +356,20 @@ Then, execute the script for validating contents: .. code-block:: terminal # validates a single file - $ php lint.php path/to/file.yml + $ php lint.php path/to/file.yaml # or all the files in a directory $ php lint.php path/to/directory # or contents passed to STDIN - $ cat path/to/file.yml | php lint.php + $ cat path/to/file.yaml | php lint.php The result is written to STDOUT and uses a plain text format by default. Add the ``--format`` option to get the output in JSON format: .. code-block:: terminal - $ php lint.php path/to/file.yml --format json + $ php lint.php path/to/file.yaml --format json .. tip:: diff --git a/email/spool.rst b/email/spool.rst index d8afa6ba88d..9c6ad04843e 100644 --- a/email/spool.rst +++ b/email/spool.rst @@ -15,6 +15,8 @@ it somewhere such as a file. Another process can then read from the spool and take care of sending the emails in the spool. Currently only spooling to file or memory is supported. +.. _email-spool-memory: + Spool Using Memory ------------------