diff --git a/_build/redirection_map b/_build/redirection_map index 8b09f4ff0cc..d617999f0b3 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -13,7 +13,7 @@ /cookbook/email /email /cookbook/gmail /cookbook/email/gmail /cookbook/console /components/console -/cookbook/tools/autoloader /components/class_loader +/cookbook/tools/autoloader https://github.com/symfony/class-loader /cookbook/tools/finder /components/finder /cookbook/service_container/parentservices /service_container/parent_services /cookbook/service_container/factories /service_container/factories @@ -295,15 +295,15 @@ /components/asset/introduction /components/asset /components/browser_kit/index /components/browser_kit /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/class_loader/introduction https://github.com/symfony/class-loader +/components/class_loader/index https://github.com/symfony/class-loader +/components/class_loader/cache_class_loader https://github.com/symfony/class-loader +/components/class_loader/class_loader https://github.com/symfony/class-loader +/components/class_loader/class_map_generator https://github.com/symfony/class-loader +/components/class_loader/debug_class_loader https://github.com/symfony/class-loader +/components/class_loader/map_class_loader https://github.com/symfony/class-loader +/components/class_loader/map_class_loader https://github.com/symfony/class-loader +/components/class_loader/psr4_class_loader https://github.com/symfony/class-loader /components/config/introduction /components/config /components/config/index /components/config /components/console/helpers/tablehelper /components/console/helpers/table @@ -350,10 +350,10 @@ /components/routing/hostname_pattern /routing/hostname_pattern /components/security/introduction /components/security /components/security/index /components/security -/components/templating/introduction /components/templating -/components/templating/index /components/templating -/components/templating/helpers/assetshelper /components/templating/assetshelper -/components/templating/helpers/slotshelper /components/templating/slotshelper +/components/templating/introduction https://github.com/symfony/templating +/components/templating/index https://github.com/symfony/templating +/components/templating/helpers/assetshelper https://github.com/symfony/templating +/components/templating/helpers/slotshelper https://github.com/symfony/templating /components/translation/introduction /components/translation /components/translation/index /components/translation /components/var_dumper/introduction /components/var_dumper @@ -399,7 +399,7 @@ /security/acl_advanced /security/acl /security/password_encoding /security /weblink /web_link -/components/weblink /components/web_link +/components/weblink https://github.com/symfony/web-link /frontend/encore/installation-no-flex /frontend/encore/installation /http_cache/form_csrf_caching /security/csrf /console/logging /console @@ -481,3 +481,25 @@ /components/routing https://github.com/symfony/routing /doctrine/pdo_session_storage /session/database /doctrine/mongodb_session_storage /session/database +/components/dotenv https://github.com/symfony/dotenv +/components/mercure https://github.com/symfony/mercure +/components/polyfill_apcu https://github.com/symfony/polyfill-apcu +/components/polyfill_ctype https://github.com/symfony/polyfill-ctype +/components/polyfill_iconv https://github.com/symfony/polyfill-iconv +/components/polyfill_intl_grapheme https://github.com/symfony/polyfill_intl-grapheme +/components/polyfill_intl_icu https://github.com/symfony/polyfill_intl-icu +/components/polyfill_intl_idn https://github.com/symfony/polyfill_intl-idn +/components/polyfill_intl_normalizer https://github.com/symfony/polyfill_intl-normalizer +/components/polyfill_mbstring https://github.com/symfony/polyfill-mbstring +/components/polyfill_php54 https://github.com/symfony/polyfill-php54 +/components/polyfill_php55 https://github.com/symfony/polyfill-php55 +/components/polyfill_php56 https://github.com/symfony/polyfill-php56 +/components/polyfill_php70 https://github.com/symfony/polyfill-php70 +/components/polyfill_php71 https://github.com/symfony/polyfill-php71 +/components/polyfill_php72 https://github.com/symfony/polyfill-php72 +/components/polyfill_php73 https://github.com/symfony/polyfill-php73 +/components/polyfill_uuid https://github.com/symfony/polyfill-uuid +/components/web_link https://github.com/symfony/web-link +/components/templating https://github.com/symfony/templating +/components/error_handler https://github.com/symfony/error-handler +/components/class_loader https://github.com/symfony/class-loader diff --git a/components/asset.rst b/components/asset.rst index a01a0d3a440..792201a2607 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -401,6 +401,6 @@ Learn more ---------- * :doc:`How to manage CSS and JavaScript assets in Symfony applications ` -* :doc:`WebLink component ` to preload assets using HTTP/2. +* :doc:`WebLink component ` to preload assets using HTTP/2. .. _`Webpack`: https://webpack.js.org/ diff --git a/components/class_loader.rst b/components/class_loader.rst deleted file mode 100644 index f3268b1ca71..00000000000 --- a/components/class_loader.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. index:: - single: Components; ClassLoader - -The ClassLoader Component -========================= - -.. caution:: - - The ClassLoader component was removed in Symfony 4.0. 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/dotenv.rst b/components/dotenv.rst deleted file mode 100644 index 0dc1a51e067..00000000000 --- a/components/dotenv.rst +++ /dev/null @@ -1,173 +0,0 @@ -.. index:: - single: Dotenv - single: Components; Dotenv - -The Dotenv Component -==================== - - The Dotenv Component parses ``.env`` files to make environment variables - stored in them accessible via ``$_ENV`` or ``$_SERVER``. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/dotenv - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Sensitive information and environment-dependent settings should be defined as -environment variables (as recommended for `twelve-factor applications`_). Using -a ``.env`` file to store those environment variables eases development and CI -management by keeping them in one "standard" place and agnostic of the -technology stack you are using (nginx vs PHP built-in server for instance). - -.. note:: - - PHP has a lot of different implementations of this "pattern". This - implementation's goal is to replicate what ``source .env`` would do. It - tries to be as similar as possible with the standard shell's behavior (so - no value validation for instance). - -Load a ``.env`` file in your PHP application via ``Dotenv::load()``:: - - use Symfony\Component\Dotenv\Dotenv; - - $dotenv = new Dotenv(); - $dotenv->load(__DIR__.'/.env'); - - // You can also load several files - $dotenv->load(__DIR__.'/.env', __DIR__.'/.env.dev'); - -Given the following ``.env`` file content: - -.. code-block:: terminal - - # .env - DB_USER=root - DB_PASS=pass - -Access the value with ``$_ENV`` in your code:: - - $dbUser = $_ENV['DB_USER']; - // you can also use ``$_SERVER`` - -The ``load()`` method never overwrites existing environment variables. Use the -``overload()`` method if you need to overwrite them:: - - // ... - $dotenv->overload(__DIR__.'/.env'); - -As you're working with the Dotenv component you'll notice that you might want -to have different files depending on the environment you're working in. Typically -this happens for local development or Continuous Integration where you might -want to have different files for your ``test`` and ``dev`` environments. - -You can use ``Dotenv::loadEnv()`` to ease this process:: - - use Symfony\Component\Dotenv\Dotenv; - - $dotenv = new Dotenv(); - $dotenv->loadEnv(__DIR__.'/.env'); - -The Dotenv component will then look for the correct ``.env`` file to load -in the following order whereas the files loaded later override the variables -defined in previously loaded files: - -#. If ``.env`` exists, it is loaded first. In case there's no ``.env`` file but a - ``.env.dist``, this one will be loaded instead. -#. If one of the previously mentioned files contains the ``APP_ENV`` variable, the - variable is populated and used to load environment-specific files hereafter. If - ``APP_ENV`` is not defined in either of the previously mentioned files, ``dev`` is - assumed for ``APP_ENV`` and populated by default. -#. If there's a ``.env.local`` representing general local environment variables it's loaded now. -#. If there's a ``.env.$env.local`` file, this one is loaded. Otherwise, it falls - back to ``.env.$env``. - -This might look complicated at first glance but it gives you the opportunity to -commit multiple environment-specific files that can then be adjusted to your -local environment. Given you commit ``.env``, ``.env.test`` and ``.env.dev`` to -represent different configuration settings for your environments, each of them -can be adjusted by using ``.env.local``, ``.env.test.local`` and -``.env.dev.local`` respectively. - -.. note:: - - ``.env.local`` is always ignored in ``test`` environment because tests should produce the - same results for everyone. - -You can adjust the variable defining the environment, default environment and test -environments by passing them as additional arguments to ``Dotenv::loadEnv()`` -(see :method:`Symfony\\Component\\Dotenv\\Dotenv::loadEnv` for details). - -.. versionadded:: 4.2 - - The ``Dotenv::loadEnv()`` method was introduced in Symfony 4.2. - -You should never store a ``.env.local`` file in your code repository as it might -contain sensitive information; create a ``.env`` file (or multiple -environment-specific ones as shown above) with sensible defaults instead. - -.. note:: - - Symfony Dotenv can be used in any environment of your application: - development, testing, staging and even production. However, in production - it's recommended to configure real environment variables to avoid the - performance overhead of parsing the ``.env`` file for every request. - -As a ``.env`` file is a regular shell script, you can ``source`` it in your own -shell scripts: - -.. code-block:: terminal - - source .env - -Add comments by prefixing them with ``#``: - -.. code-block:: terminal - - # Database credentials - DB_USER=root - DB_PASS=pass # This is the secret password - -Use environment variables in values by prefixing variables with ``$``: - -.. code-block:: terminal - - DB_USER=root - DB_PASS=${DB_USER}pass # Include the user as a password prefix - -.. note:: - - The order is important when some env var depends on the value of other env - vars. In the above example, ``DB_PASS`` must be defined after ``DB_USER``. - Moreover, if you define multiple ``.env`` files and put ``DB_PASS`` first, - its value will depend on the ``DB_USER`` value defined in other files - instead of the value defined in this file. - -Define a default value in case the environment variable is not set: - -.. code-block:: terminal - - DB_USER= - DB_PASS=${DB_USER:-root}pass # results in DB_PASS=rootpass - -.. versionadded:: 4.4 - - The support for default values has been introduced in Symfony 4.4. - -Embed commands via ``$()`` (not supported on Windows): - -.. code-block:: terminal - - START_TIME=$(date) - -.. note:: - - Note that using ``$()`` might not work depending on your shell. - -.. _twelve-factor applications: https://12factor.net/ diff --git a/components/error_handler.rst b/components/error_handler.rst deleted file mode 100644 index ef4fded3cee..00000000000 --- a/components/error_handler.rst +++ /dev/null @@ -1,138 +0,0 @@ -.. index:: - single: Debug - single: Error - single: Exception - single: Components; ErrorHandler - -The ErrorHandler Component -========================== - - The ErrorHandler component provides tools to manage errors and ease - debugging PHP code. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/error-handler - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -The ErrorHandler component provides several tools to help you debug PHP code. -Call this method (e.g. in your :ref:`front controller `) -to enable all of them in your application:: - - // public/index.php - use Symfony\Component\ErrorHandler\Debug; - - if ($_SERVER['APP_DEBUG']) { - Debug::enable(); - } - - // ... - -Keep reading this article to learn more about each feature, including how to -enable each of them separately. - -.. caution:: - - You should never enable the debug tools, except for the error handler, in a - production environment as they might disclose sensitive information to the user. - -.. _turning-php-errors-into-exceptions: - -Turning PHP Errors into Exceptions ----------------------------------- - -The :class:`Symfony\\Component\\ErrorHandler\\ErrorHandler` class catches PHP -errors and uncaught PHP exceptions and turns them into PHP's -:phpclass:`ErrorException` objects, except for fatal PHP errors, which are -turned into Symfony's :class:`Symfony\\Component\\ErrorHandler\\Error\\FatalError` -objects. - -If the application uses the FrameworkBundle, this error handler is enabled by -default in the :ref:`production environment ` -because it generates better error logs. - -Use the following code (e.g. in your :ref:`front controller `) -to enable this error handler:: - - use Symfony\Component\ErrorHandler\ErrorHandler; - - ErrorHandler::register(); - -Catching PHP Function Errors and Turning Them into Exceptions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Consider the following example:: - - $data = json_decode(file_get_contents($filename), true); - $data['read_at'] = date($datetimeFormat); - file_put_contents($filename, json_encode($data)); - -Most PHP core functions were written before exception handling was introduced, -so they return ``false`` or ``null`` in case of error instead of throwing an -exception. That's why you need to add something like these to check for errors:: - - $content = @file_get_contents($filename); - if (false === $content) { - throw new \RuntimeException('Could not load file.'); - } - - // since PHP 7.3 json_decode() defines an option to throw JSON_THROW_ON_ERROR - // but you need to enable that option explicitly - $data = @json_decode($content, true); - if (null === $data) { - throw new \RuntimeException('File does not contain valid JSON.'); - } - - $datetime = @date($datetimeFormat); - if (false === $datetime) { - throw new \RuntimeException('Invalid datetime format.'); - } - -To simplify this code, the :class:`Symfony\\Component\\ErrorHandler\\ErrorHandler` -class provides a :method:`Symfony\\Component\\ErrorHandler\\ErrorHandler::call` -method that throws an exception automatically when a PHP error occurs:: - - $content = ErrorHandler::call('file_get_contents', $filename); - -The first argument of ``call()`` is the name of the PHP function to execute and -the rest of arguments are passed to the PHP function. The result of the PHP -function is returned as the result of ``call()``. - -You can pass any PHP callable as the first argument of ``call()``, so you can -wrap several function calls inside an anonymous function:: - - $data = ErrorHandler::call(static function () use ($filename, $datetimeFormat) { - // if any code executed inside this anonymous function fails, a PHP exception - // will be thrown, even if the code uses the '@' PHP silence operator - $data = json_decode(file_get_contents($filename), true); - $data['read_at'] = date($datetimeFormat); - file_put_contents($filename, json_encode($data)); - - return $data; - }); - -.. _component-debug-class-loader: - -Class Loading Debugger ----------------------- - -The :class:`Symfony\\Component\\ErrorHandler\\DebugClassLoader` class throws -more useful exceptions when a class isn't found by the registered autoloaders -(e.g. looks for typos in the class names and suggest the right class name). - -In practice, this debugger looks for all registered autoloaders that implement a -``findFile()`` method and replaces them by its own method to find class files. - -Use the following code (e.g. in your :ref:`front controller `) -to enable this class loading debugger:: - - use Symfony\Component\ErrorHandler\DebugClassLoader; - - DebugClassLoader::enable(); diff --git a/components/mercure.rst b/components/mercure.rst deleted file mode 100644 index 9ad99419e8e..00000000000 --- a/components/mercure.rst +++ /dev/null @@ -1,46 +0,0 @@ -.. index:: - single: Mercure - single: Components; Mercure - -The Mercure Component -===================== - - `Mercure`_ is an open protocol allowing to push data updates to web - browsers and other HTTP clients in a convenient, fast, reliable - and battery-friendly way. - It is especially useful to publish real-time updates of resources served - through web APIs, to reactive web and mobile applications. - -The Mercure Component implements the "publisher" part of the Mercure Protocol. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/mercure - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -The following example shows the component in action:: - - // change these values accordingly to your hub installation - define('HUB_URL', 'https://demo.mercure.rocks/.well-known/mercure'); - define('JWT', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.LRLvirgONK13JgacQ_VbcjySbVhkSmHy3IznH3tA9PM'); - - use Symfony\Component\Mercure\Jwt\StaticJwtProvider; - use Symfony\Component\Mercure\Publisher; - use Symfony\Component\Mercure\Update; - - $publisher = new Publisher(HUB_URL, new StaticJwtProvider(JWT)); - // Serialize the update, and dispatch it to the hub, that will broadcast it to the clients - $id = $publisher(new Update('https://example.com/books/1.jsonld', 'Hi from Symfony!', ['target1', 'target2'])); - -Read the full :doc:`Mercure integration documentation ` to learn -about all the features of this component and its integration with the Symfony -framework. - -.. _`Mercure`: https://mercure.rocks diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 3f6563afefa..c5a85265f8c 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -311,9 +311,8 @@ Deprecation Notices at Autoloading Time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, the PHPUnit Bridge uses ``DebugClassLoader`` from the -:doc:`ErrorHandler component ` to throw deprecation -notices at class autoloading time. This can be disabled with the -``debug-class-loader`` option. +`ErrorHandler component`_ to throw deprecation notices at class autoloading +time. This can be disabled with the ``debug-class-loader`` option. .. code-block:: xml @@ -970,6 +969,7 @@ not find the SUT: .. _`PHPUnit`: https://phpunit.de .. _`PHPUnit event listener`: https://phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener +.. _`ErrorHandler component`: https://github.com/symfony/error-handler .. _`PHPUnit's assertStringMatchesFormat()`: https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertStringMatchesFormat .. _`PHP error handler`: https://www.php.net/manual/en/book.errorfunc.php .. _`environment variable`: https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables diff --git a/components/polyfill_apcu.rst b/components/polyfill_apcu.rst deleted file mode 100644 index 80f7aeef809..00000000000 --- a/components/polyfill_apcu.rst +++ /dev/null @@ -1,50 +0,0 @@ -.. index:: - single: Polyfill - single: APC - single: Components; Polyfill - -The Symfony Polyfill / APCu Component -===================================== - - This component provides ``apcu_*`` functions and the ``APCUIterator`` class - to users of the legacy APC extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-apcu - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -classes and functions, no matter if the `PHP APCu extension`_ is installed or -not in your server. The only requirement is to have installed at least the -`legacy APC extension`_. - -Provided Classes -~~~~~~~~~~~~~~~~ - -* :phpclass:`APCUIterator` - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`apcu_add` -* :phpfunction:`apcu_delete` -* :phpfunction:`apcu_exists` -* :phpfunction:`apcu_fetch` -* :phpfunction:`apcu_store` -* :phpfunction:`apcu_cache_info` -* :phpfunction:`apcu_cas` -* :phpfunction:`apcu_clear_cache` -* :phpfunction:`apcu_dec` -* :phpfunction:`apcu_inc` -* :phpfunction:`apcu_sma_info` - -.. _`PHP APCu extension`: https://secure.php.net/manual/en/book.apcu.php -.. _`legacy APC extension`: https://secure.php.net/manual/en/book.apc.php diff --git a/components/polyfill_ctype.rst b/components/polyfill_ctype.rst deleted file mode 100644 index f685a8563a2..00000000000 --- a/components/polyfill_ctype.rst +++ /dev/null @@ -1,43 +0,0 @@ -.. index:: - single: Polyfill - single: Ctype - single: Components; Polyfill - -The Symfony Polyfill / Ctype Component -====================================== - - This component provides ``ctype_*`` functions to users who run PHP versions - without the ctype extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-ctype - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -functions, no matter if the `PHP Ctype extension`_ is installed or not in your -server. - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`ctype_alnum` -* :phpfunction:`ctype_alpha` -* :phpfunction:`ctype_cntrl` -* :phpfunction:`ctype_digit` -* :phpfunction:`ctype_graph` -* :phpfunction:`ctype_lower` -* :phpfunction:`ctype_print` -* :phpfunction:`ctype_punct` -* :phpfunction:`ctype_space` -* :phpfunction:`ctype_upper` -* :phpfunction:`ctype_xdigit` - -.. _`PHP Ctype extension`: https://secure.php.net/manual/en/book.ctype.php diff --git a/components/polyfill_iconv.rst b/components/polyfill_iconv.rst deleted file mode 100644 index e50b926e6bd..00000000000 --- a/components/polyfill_iconv.rst +++ /dev/null @@ -1,57 +0,0 @@ -.. index:: - single: Polyfill - single: Iconv - single: Components; Polyfill - -The Symfony Polyfill / Iconv Component -====================================== - - This component provides a native PHP implementation of the ``iconv_*`` - functions to users who run PHP versions without the ``iconv`` extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-iconv - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -constants and functions, no matter if the `PHP iconv extension`_ is installed or -not in your server. The only function not implemented in this component is -:phpfunction:`ob_iconv_handler`. - -Provided Constants -~~~~~~~~~~~~~~~~~~ - -* ``ICONV_IMPL`` (value = ``'Symfony'``) -* ``ICONV_VERSION`` (value = ``'1.0'``) -* ``ICONV_MIME_DECODE_STRICT`` (value = ``1``) -* ``ICONV_MIME_DECODE_CONTINUE_ON_ERROR`` (value = ``2``) - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -These functions are always available: - -* :phpfunction:`iconv` -* :phpfunction:`iconv_get_encoding` -* :phpfunction:`iconv_set_encoding` -* :phpfunction:`iconv_mime_encode` -* :phpfunction:`iconv_mime_decode_headers` - -These functions are only available when the ``mbstring`` or the ``xml`` -extension are installed: - -* :phpfunction:`iconv_strlen` -* :phpfunction:`iconv_strpos` -* :phpfunction:`iconv_strrpos` -* :phpfunction:`iconv_substr` -* :phpfunction:`iconv_mime_decode` - -.. _`PHP iconv extension`: https://secure.php.net/manual/en/book.iconv.php diff --git a/components/polyfill_intl_grapheme.rst b/components/polyfill_intl_grapheme.rst deleted file mode 100644 index cb5b020c59b..00000000000 --- a/components/polyfill_intl_grapheme.rst +++ /dev/null @@ -1,58 +0,0 @@ -.. index:: - single: Polyfill - single: Intl - single: Components; Polyfill - -The Symfony Polyfill / Intl Grapheme Component -============================================== - - This component provides a partial, native PHP implementation of the - ``grapheme_*`` functions to users who run PHP versions without the ``intl`` - extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-intl-grapheme - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -constants and functions, no matter if the `PHP intl extension`_ is installed or -not in your server. - -Provided Constants -~~~~~~~~~~~~~~~~~~ - -* ``GRAPHEME_EXTR_COUNT`` (value = ``0``) -* ``GRAPHEME_EXTR_MAXBYTES`` (value = ``1``) -* ``GRAPHEME_EXTR_MAXCHARS`` (value = ``2``) - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`grapheme_extract` -* :phpfunction:`grapheme_stripos` -* :phpfunction:`grapheme_stristr` -* :phpfunction:`grapheme_strlen` -* :phpfunction:`grapheme_strpos` -* :phpfunction:`grapheme_strripos` -* :phpfunction:`grapheme_strrpos` -* :phpfunction:`grapheme_strstr` -* :phpfunction:`grapheme_substr` - -.. seealso:: - - Symfony provides more polyfills for other classes and functions related to - the Intl PHP extension: - :doc:`polyfill-intl-icu `, - :doc:`polyfill-intl-idn `, - :doc:`polyfill-intl-messageformatter `, - and :doc:`polyfill-intl-normalizer `. - -.. _`PHP intl extension`: https://secure.php.net/manual/en/book.intl.php diff --git a/components/polyfill_intl_icu.rst b/components/polyfill_intl_icu.rst deleted file mode 100644 index a00fb7ed35c..00000000000 --- a/components/polyfill_intl_icu.rst +++ /dev/null @@ -1,54 +0,0 @@ -.. index:: - single: Polyfill - single: ICU - single: Components; Polyfill - -The Symfony Polyfill / Intl ICU Component -========================================= - - This component provides a native PHP implementation of several Intl - functions and classes to users who run PHP versions without the ``intl`` - extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-intl-icu - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -classes and functions, no matter if the `PHP intl extension`_ is installed or -not in your server. - -Provided Classes -~~~~~~~~~~~~~~~~ - -* :phpclass:`Collator` -* :phpclass:`IntlDateFormatter` -* :phpclass:`Locale` -* :phpclass:`NumberFormatter` - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`intl_error_name` -* :phpfunction:`intl_get_error_code` -* :phpfunction:`intl_get_error_message` -* :phpfunction:`intl_is_failure` - -.. seealso:: - - Symfony provides more polyfills for other classes and functions related to - the Intl PHP extension: - :doc:`polyfill-intl-grapheme `, - :doc:`polyfill-intl-idn `, - :doc:`polyfill-intl-messageformatter `, - and :doc:`polyfill-intl-normalizer `. - -.. _`PHP intl extension`: https://secure.php.net/manual/en/book.intl.php diff --git a/components/polyfill_intl_idn.rst b/components/polyfill_intl_idn.rst deleted file mode 100644 index 9314f0af35b..00000000000 --- a/components/polyfill_intl_idn.rst +++ /dev/null @@ -1,43 +0,0 @@ -.. index:: - single: Polyfill - single: IDN - single: Components; Polyfill - -The Symfony Polyfill / Intl IDN Component -========================================= - - This component provides a collection of functions related to IDN when the - Intl extension is not installed. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-intl-idn - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -functions, no matter if the `PHP intl extension`_ is installed or not in your -server. - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`idn_to_ascii` -* :phpfunction:`idn_to_utf8` - -.. seealso:: - - Symfony provides more polyfills for other classes and functions related to - the Intl PHP extension: - :doc:`polyfill-intl-grapheme `, - :doc:`polyfill-intl-icu `, - :doc:`polyfill-intl-messageformatter `, - and :doc:`polyfill-intl-normalizer `. - -.. _`PHP intl extension`: https://secure.php.net/manual/en/book.intl.php diff --git a/components/polyfill_intl_messageformatter.rst b/components/polyfill_intl_messageformatter.rst deleted file mode 100644 index b07533d1e16..00000000000 --- a/components/polyfill_intl_messageformatter.rst +++ /dev/null @@ -1,48 +0,0 @@ -.. index:: - single: Polyfill - single: MessageFormatter - single: Components; Polyfill - -The Symfony Polyfill / Intl MessageFormatter Component -====================================================== - - This component provides a fallback implementation for the ``MessageFormatter`` - class to users who run PHP versions without the ``intl`` extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-intl-messageformatter - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -classes and functions, no matter if the `PHP intl extension`_ is installed or -not in your server. - -Provided Classes -~~~~~~~~~~~~~~~~ - -* :phpclass:`IntlException` -* :phpclass:`MessageFormatter` - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`msgfmt_format_message` - -.. seealso:: - - Symfony provides more polyfills for other classes and functions related to - the Intl PHP extension: - :doc:`polyfill-intl-grapheme `, - :doc:`polyfill-intl-idn `, - :doc:`polyfill-intl-icu `, - and :doc:`polyfill-intl-normalizer `. - -.. _`PHP intl extension`: https://secure.php.net/manual/en/book.intl.php diff --git a/components/polyfill_intl_normalizer.rst b/components/polyfill_intl_normalizer.rst deleted file mode 100644 index a9c4ae01a32..00000000000 --- a/components/polyfill_intl_normalizer.rst +++ /dev/null @@ -1,48 +0,0 @@ -.. index:: - single: Polyfill - single: Normalizer - single: Components; Polyfill - -The Symfony Polyfill / Intl Normalizer Component -================================================ - - This component provides a fallback implementation for the ``Normalizer`` - class to users who run PHP versions without the ``intl`` extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-intl-normalizer - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -classes and functions, no matter if the `PHP intl extension`_ is installed or -not in your server. - -Provided Classes -~~~~~~~~~~~~~~~~ - -* :phpclass:`Normalizer` - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`normalizer_is_normalized` -* :phpfunction:`normalizer_normalize` - -.. seealso:: - - Symfony provides more polyfills for other classes and functions related to - the Intl PHP extension: - :doc:`polyfill-intl-grapheme `, - :doc:`polyfill-intl-idn `, - :doc:`polyfill-intl-icu `, - and :doc:`polyfill-intl-messageformatter `. - -.. _`PHP intl extension`: https://secure.php.net/manual/en/book.intl.php diff --git a/components/polyfill_mbstring.rst b/components/polyfill_mbstring.rst deleted file mode 100644 index 322f1e338fc..00000000000 --- a/components/polyfill_mbstring.rst +++ /dev/null @@ -1,76 +0,0 @@ -.. index:: - single: Polyfill - single: Mbstring - single: Components; Polyfill - -The Symfony Polyfill / Mbstring Component -========================================= - - This component provides a partial, native PHP implementation for the - ``mbstring`` PHP extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-mbstring - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -constants and functions, no matter if the `PHP mbstring extension`_ is installed -or not in your server. - -Provided Constants -~~~~~~~~~~~~~~~~~~ - -* ``MB_CASE_UPPER`` (value = ``0``) -* ``MB_CASE_LOWER`` (value = ``1``) -* ``MB_CASE_TITLE`` (value = ``2``) - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`mb_check_encoding` -* :phpfunction:`mb_chr` -* :phpfunction:`mb_convert_case` -* :phpfunction:`mb_convert_encoding` -* :phpfunction:`mb_convert_variables` -* :phpfunction:`mb_decode_mimeheader` -* :phpfunction:`mb_decode_numericentity` -* :phpfunction:`mb_detect_encoding` -* :phpfunction:`mb_detect_order` -* :phpfunction:`mb_encode_mimeheader` -* :phpfunction:`mb_encode_numericentity` -* :phpfunction:`mb_encoding_aliases` -* :phpfunction:`mb_get_info` -* :phpfunction:`mb_http_input` -* :phpfunction:`mb_http_output` -* :phpfunction:`mb_internal_encoding` -* :phpfunction:`mb_language` -* :phpfunction:`mb_list_encodings` -* :phpfunction:`mb_ord` -* :phpfunction:`mb_output_handler` -* :phpfunction:`mb_parse_str` -* :phpfunction:`mb_scrub` -* :phpfunction:`mb_stripos` -* :phpfunction:`mb_stristr` -* :phpfunction:`mb_strlen` -* :phpfunction:`mb_strpos` -* :phpfunction:`mb_strrchr` -* :phpfunction:`mb_strrichr` -* :phpfunction:`mb_strripos` -* :phpfunction:`mb_strrpos` -* :phpfunction:`mb_strstr` -* :phpfunction:`mb_strtolower` -* :phpfunction:`mb_strtoupper` -* :phpfunction:`mb_strwidth` -* :phpfunction:`mb_substitute_character` -* :phpfunction:`mb_substr_count` -* :phpfunction:`mb_substr` - -.. _`PHP mbstring extension`: https://secure.php.net/manual/en/book.mbstring.php diff --git a/components/polyfill_php54.rst b/components/polyfill_php54.rst deleted file mode 100644 index 7c2019a0dba..00000000000 --- a/components/polyfill_php54.rst +++ /dev/null @@ -1,33 +0,0 @@ -.. index:: - single: Polyfill - single: PHP - single: Components; Polyfill - -The Symfony Polyfill / PHP 5.4 Component -======================================== - - This component provides some PHP 5.4 features to applications using earlier - PHP versions. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-php54 - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -functions, no matter if your PHP version is earlier than PHP 5.4. - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`class_uses` -* :phpfunction:`hex2bin` -* :phpfunction:`session_register_shutdown` -* :phpfunction:`trait_exists` diff --git a/components/polyfill_php55.rst b/components/polyfill_php55.rst deleted file mode 100644 index 99650499763..00000000000 --- a/components/polyfill_php55.rst +++ /dev/null @@ -1,37 +0,0 @@ -.. index:: - single: Polyfill - single: PHP - single: Components; Polyfill - -The Symfony Polyfill / PHP 5.5 Component -======================================== - - This component provides some PHP 5.5 features to applications using earlier - PHP versions. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-php55 - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -functions, no matter if your PHP version is earlier than PHP 5.5. - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`array_column` -* :phpfunction:`boolval` -* :phpfunction:`hash_pbkdf2` -* :phpfunction:`json_last_error_msg` -* :phpfunction:`password_get_info` -* :phpfunction:`password_hash` -* :phpfunction:`password_needs_rehash` -* :phpfunction:`password_verify` diff --git a/components/polyfill_php56.rst b/components/polyfill_php56.rst deleted file mode 100644 index c68e8d46fd8..00000000000 --- a/components/polyfill_php56.rst +++ /dev/null @@ -1,37 +0,0 @@ -.. index:: - single: Polyfill - single: PHP - single: Components; Polyfill - -The Symfony Polyfill / PHP 5.6 Component -======================================== - - This component provides some PHP 5.6 features to applications using earlier - PHP versions. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-php56 - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -constants and functions, no matter if your PHP version is earlier than PHP 5.6. - -Provided Constants -~~~~~~~~~~~~~~~~~~ - -* ``LDAP_ESCAPE_FILTER`` (value = ``1``) -* ``LDAP_ESCAPE_DN`` (value = ``2``) - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`hash_equals` -* :phpfunction:`ldap_escape` diff --git a/components/polyfill_php70.rst b/components/polyfill_php70.rst deleted file mode 100644 index 2169173faf0..00000000000 --- a/components/polyfill_php70.rst +++ /dev/null @@ -1,51 +0,0 @@ -.. index:: - single: Polyfill - single: PHP - single: Components; Polyfill - -The Symfony Polyfill / PHP 7.0 Component -======================================== - - This component provides some PHP 7.0 features to applications using earlier - PHP versions. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-php70 - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -constants, classes and functions, no matter if your PHP version is earlier than -PHP 7.0. - -Provided Constants -~~~~~~~~~~~~~~~~~~ - -* ``PHP_INT_MIN`` (value = ``~PHP_INT_MAX``) - -Provided Classes -~~~~~~~~~~~~~~~~ - -* :phpclass:`ArithmeticError` -* :phpclass:`AssertionError` -* :phpclass:`DivisionByZeroError` -* :phpclass:`Error` -* :phpclass:`ParseError` -* :phpclass:`SessionUpdateTimestampHandlerInterface` -* :phpclass:`TypeError` - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`error_clear_last` -* :phpfunction:`intdiv` -* :phpfunction:`preg_replace_callback_array` -* :phpfunction:`random_bytes` -* :phpfunction:`random_int` diff --git a/components/polyfill_php71.rst b/components/polyfill_php71.rst deleted file mode 100644 index 1cec61b4fa6..00000000000 --- a/components/polyfill_php71.rst +++ /dev/null @@ -1,30 +0,0 @@ -.. index:: - single: Polyfill - single: PHP - single: Components; Polyfill - -The Symfony Polyfill / PHP 7.1 Component -======================================== - - This component provides some PHP 7.1 features to applications using earlier - PHP versions. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-php71 - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -functions, no matter if your PHP version is earlier than PHP 7.1. - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`is_iterable` diff --git a/components/polyfill_php72.rst b/components/polyfill_php72.rst deleted file mode 100644 index 1a0d0bf87ca..00000000000 --- a/components/polyfill_php72.rst +++ /dev/null @@ -1,39 +0,0 @@ -.. index:: - single: Polyfill - single: PHP - single: Components; Polyfill - -The Symfony Polyfill / PHP 7.2 Component -======================================== - - This component provides some PHP 7.2 features to applications using earlier - PHP versions. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-php72 - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -constants and functions, no matter if your PHP version is earlier than PHP 7.2. - -Provided Constants -~~~~~~~~~~~~~~~~~~ - -* ``PHP_OS_FAMILY`` (value = depends on your operating system) - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`sapi_windows_vt100_support` (only on Windows systems) -* :phpfunction:`spl_object_id` -* :phpfunction:`stream_isatty` -* :phpfunction:`utf8_decode` -* :phpfunction:`utf8_encode` diff --git a/components/polyfill_php73.rst b/components/polyfill_php73.rst deleted file mode 100644 index be04e57cb63..00000000000 --- a/components/polyfill_php73.rst +++ /dev/null @@ -1,33 +0,0 @@ -.. index:: - single: Polyfill - single: PHP - single: Components; Polyfill - -The Symfony Polyfill / PHP 7.3 Component -======================================== - - This component provides some PHP 7.3 features to applications using earlier - PHP versions. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-php73 - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -functions, no matter if your PHP version is earlier than PHP 7.3. - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`is_countable` -* :phpfunction:`hrtime` -* :phpfunction:`array_key_first` -* :phpfunction:`array_key_last` diff --git a/components/polyfill_uuid.rst b/components/polyfill_uuid.rst deleted file mode 100644 index 0fd080d39d4..00000000000 --- a/components/polyfill_uuid.rst +++ /dev/null @@ -1,57 +0,0 @@ -.. index:: - single: Polyfill - single: PHP - single: Components; Polyfill - -The Symfony Polyfill / UUID Component -===================================== - - This component provides ``uuid_*`` functions to users who run PHP versions - without the UUID extension. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/polyfill-uuid - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -Once this component is installed in your application, you can use the following -functions, no matter if the `PHP UUID extension`_ is installed or not in your -server. - -Provided Constants -~~~~~~~~~~~~~~~~~~ - -* ``UUID_VARIANT_NCS`` (value = 0) -* ``UUID_VARIANT_DCE`` (value = 1) -* ``UUID_VARIANT_MICROSOFT`` (value = 2) -* ``UUID_VARIANT_OTHER`` (value = 3) -* ``UUID_TYPE_DEFAULT`` (value = 0) -* ``UUID_TYPE_TIME`` (value = 1) -* ``UUID_TYPE_DCE`` (value = 4) -* ``UUID_TYPE_NAME`` (value = 1) -* ``UUID_TYPE_RANDOM`` (value = 4) -* ``UUID_TYPE_NULL`` (value = -1) -* ``UUID_TYPE_INVALID`` (value = -42) - -Provided Functions -~~~~~~~~~~~~~~~~~~ - -* :phpfunction:`uuid_create` -* :phpfunction:`uuid_is_valid` -* :phpfunction:`uuid_compare` -* :phpfunction:`uuid_is_null` -* :phpfunction:`uuid_type` -* :phpfunction:`uuid_variant` -* :phpfunction:`uuid_time` -* :phpfunction:`uuid_mac` -* :phpfunction:`uuid_parse` -* :phpfunction:`uuid_unparse` - -.. _`PHP UUID extension`: https://pecl.php.net/package/uuid diff --git a/components/templating.rst b/components/templating.rst deleted file mode 100644 index a104ea3e1d8..00000000000 --- a/components/templating.rst +++ /dev/null @@ -1,215 +0,0 @@ -.. index:: - single: Templating - single: Components; Templating - -The Templating Component -======================== - - The Templating component provides all the tools needed to build any kind - of template system. - - It provides an infrastructure to load template files and optionally - monitor them for changes. It also provides a concrete template engine - implementation using PHP with additional tools for escaping and separating - templates into blocks and layouts. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/templating - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -.. seealso:: - - This article explains how to use the Templating features as an independent - component in any PHP application. Read the article about :doc:`templates ` - to learn about how to work with templates in Symfony applications. - -The :class:`Symfony\\Component\\Templating\\PhpEngine` class is the entry point -of the component. It needs a -template name parser (:class:`Symfony\\Component\\Templating\\TemplateNameParserInterface`) -to convert a template name to a -template reference (:class:`Symfony\\Component\\Templating\\TemplateReferenceInterface`). -It also needs a template loader (:class:`Symfony\\Component\\Templating\\Loader\\LoaderInterface`) -which uses the template reference to actually find and load the template:: - - use Symfony\Component\Templating\Loader\FilesystemLoader; - use Symfony\Component\Templating\PhpEngine; - use Symfony\Component\Templating\TemplateNameParser; - - $filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%'); - - $templating = new PhpEngine(new TemplateNameParser(), $filesystemLoader); - - echo $templating->render('hello.php', ['firstname' => 'Fabien']); - -.. code-block:: html+php - - - Hello, ! - -The :method:`Symfony\\Component\\Templating\\PhpEngine::render` method parses -the ``views/hello.php`` file and returns the output text. The second argument -of ``render`` is an array of variables to use in the template. In this -example, the result will be ``Hello, Fabien!``. - -.. note:: - - Templates will be cached in the memory of the engine. This means that if - you render the same template multiple times in the same request, the - template will only be loaded once from the file system. - -The ``$view`` Variable ----------------------- - -In all templates parsed by the ``PhpEngine``, you get access to a mysterious -variable called ``$view``. That variable holds the current ``PhpEngine`` -instance. That means you get access to a bunch of methods that make your life -easier. - -Including Templates -------------------- - -The best way to share a snippet of template code is to create a template that -can then be included by other templates. As the ``$view`` variable is an -instance of ``PhpEngine``, you can use the ``render()`` method (which was used -to render the template originally) inside the template to render another template:: - - - - render('hello.php', ['firstname' => $name]) ?> - - -Global Variables ----------------- - -Sometimes, you need to set a variable which is available in all templates -rendered by an engine (like the ``$app`` variable when using the Symfony -Framework). These variables can be set by using the -:method:`Symfony\\Component\\Templating\\PhpEngine::addGlobal` method and they -can be accessed in the template as normal variables:: - - $templating->addGlobal('ga_tracking', 'UA-xxxxx-x'); - -In a template: - -.. code-block:: html+php - -

The google tracking code is:

- -.. caution:: - - The global variables cannot be called ``this`` or ``view``, since they are - already used by the PHP engine. - -.. note:: - - The global variables can be overridden by a local variable in the template - with the same name. - -Output Escaping ---------------- - -When you render variables, you should probably escape them so that HTML or -JavaScript code isn't written out to your page. This will prevent things like -XSS attacks. To do this, use the -:method:`Symfony\\Component\\Templating\\PhpEngine::escape` method:: - - escape($firstname) ?> - -By default, the ``escape()`` method assumes that the variable is outputted -within an HTML context. The second argument lets you change the context. For -example, to output something inside JavaScript, use the ``js`` context:: - - escape($var, 'js') ?> - -The component comes with an HTML and JS escaper. You can register your own -escaper using the -:method:`Symfony\\Component\\Templating\\PhpEngine::setEscaper` method:: - - $templating->setEscaper('css', function ($value) { - // ... all CSS escaping - - return $escapedValue; - }); - -Helpers -------- - -The Templating component can be extended via helpers. Helpers are PHP objects -that provide features useful in a template context. The component has one -built-in helper: - -* :doc:`/components/templating/slotshelper` - -Before you can use these helpers, you need to register them using -:method:`Symfony\\Component\\Templating\\PhpEngine::set`:: - - use Symfony\Component\Templating\Helper\SlotsHelper; - // ... - - $templating->set(new SlotsHelper()); - -Custom Helpers -~~~~~~~~~~~~~~ - -You can create your own helpers by creating a class which implements -:class:`Symfony\\Component\\Templating\\Helper\\HelperInterface`. However, -most of the time you'll extend -:class:`Symfony\\Component\\Templating\\Helper\\Helper`. - -The ``Helper`` has one required method: -:method:`Symfony\\Component\\Templating\\Helper\\HelperInterface::getName`. -This is the name that is used to get the helper from the ``$view`` object. - -Creating a Custom Engine ------------------------- - -Besides providing a PHP templating engine, you can also create your own engine -using the Templating component. To do that, create a new class which -implements the :class:`Symfony\\Component\\Templating\\EngineInterface`. This -requires 3 method: - -* :method:`render($name, array $parameters = []) ` - - Renders a template -* :method:`exists($name) ` - - Checks if the template exists -* :method:`supports($name) ` - - Checks if the given template can be handled by this engine. - -Using Multiple Engines ----------------------- - -It is possible to use multiple engines at the same time using the -:class:`Symfony\\Component\\Templating\\DelegatingEngine` class. This class -takes a list of engines and acts just like a normal templating engine. The -only difference is that it delegates the calls to one of the other engines. To -choose which one to use for the template, the -:method:`EngineInterface::supports() ` -method is used:: - - use Acme\Templating\CustomEngine; - use Symfony\Component\Templating\DelegatingEngine; - use Symfony\Component\Templating\PhpEngine; - - $templating = new DelegatingEngine([ - new PhpEngine(...), - new CustomEngine(...), - ]); - -Learn More ----------- - -.. toctree:: - :maxdepth: 1 - :glob: - - /components/templating/* - /templates - /templating/* diff --git a/components/templating/slotshelper.rst b/components/templating/slotshelper.rst deleted file mode 100644 index 42c088c9fd9..00000000000 --- a/components/templating/slotshelper.rst +++ /dev/null @@ -1,87 +0,0 @@ -.. index:: - single: Templating Helpers; Slots Helper - -Slots Helper -============ - -More often than not, templates in a project share common elements, like the -well-known header and footer. Using this helper, the static HTML code can -be placed in a layout file along with "slots", which represent the dynamic -parts that will change on a page-by-page basis. These slots are then filled -in by different children template. In other words, the layout file decorates -the child template. - -Displaying Slots ----------------- - -The slots are accessible by using the slots helper (``$view['slots']``). Use -:method:`Symfony\\Component\\Templating\\Helper\\SlotsHelper::output` to -display the content of the slot on that place: - -.. code-block:: html+php - - - - - - - <?php $view['slots']->output('title', 'Default title') ?> - - - - output('_content') ?> - - - -The first argument of the method is the name of the slot. The method has an -optional second argument, which is the default value to use if the slot is not -available. - -The ``_content`` slot is a special slot set by the ``PhpEngine``. It contains -the content of the sub-template. - -.. caution:: - - If you're using the standalone component, make sure you registered the - :class:`Symfony\\Component\\Templating\\Helper\\SlotsHelper`:: - - use Symfony\Component\Templating\Helper\SlotsHelper; - - // ... - $templateEngine->set(new SlotsHelper()); - -Extending Templates -------------------- - -The :method:`Symfony\\Component\\Templating\\PhpEngine::extend` method is called in the -sub-template to set its parent template. Then -:method:`$view['slots']->set() ` -can be used to set the content of a slot. All content which is not explicitly -set in a slot is in the ``_content`` slot. - -.. code-block:: html+php - - - extend('layout.php') ?> - - set('title', $page->title) ?> - -

- title ?> -

-

- body ?> -

- -.. note:: - - Multiple levels of inheritance is possible: a layout can extend another - layout. - -For large slots, there is also an extended syntax: - -.. code-block:: html+php - - start('title') ?> - Some large amount of HTML - stop() ?> diff --git a/components/web_link.rst b/components/web_link.rst deleted file mode 100644 index 4a89d0c0b48..00000000000 --- a/components/web_link.rst +++ /dev/null @@ -1,41 +0,0 @@ -.. index:: - single: WebLink - single: Components; WebLink - -The WebLink Component -====================== - - The WebLink component provides tools to manage the ``Link`` HTTP header needed - for `Web Linking`_ when using `HTTP/2 Server Push`_ as well as `Resource Hints`_. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/web-link - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -The following example shows the component in action:: - - use Symfony\Component\WebLink\GenericLinkProvider; - use Symfony\Component\WebLink\HttpHeaderSerializer; - use Symfony\Component\WebLink\Link; - - $linkProvider = (new GenericLinkProvider()) - ->withLink(new Link('preload', '/bootstrap.min.css')); - - header('Link: '.(new HttpHeaderSerializer())->serialize($linkProvider->getLinks())); - - echo 'Hello'; - -Read the full :doc:`WebLink documentation ` to learn about all the -features of the component and its integration with the Symfony framework. - -.. _`Web Linking`: https://tools.ietf.org/html/rfc5988 -.. _`HTTP/2 Server Push`: https://tools.ietf.org/html/rfc7540#section-8.2 -.. _`Resource Hints`: https://www.w3.org/TR/resource-hints/ diff --git a/configuration.rst b/configuration.rst index fb12f55db91..8a0f8b278ba 100644 --- a/configuration.rst +++ b/configuration.rst @@ -543,6 +543,62 @@ In addition to your own env vars, this ``.env`` file also contains the env vars defined by the third-party packages installed in your application (they are added automatically by :ref:`Symfony Flex ` when installing packages). +.env File Syntax +................ + +Add comments by prefixing them with ``#``: + +.. code-block:: bash + + # database credentials + DB_USER=root + DB_PASS=pass # this is the secret password + +Use environment variables in values by prefixing variables with ``$``: + +.. code-block:: bash + + DB_USER=root + DB_PASS=${DB_USER}pass # include the user as a password prefix + +.. caution:: + + The order is important when some env var depends on the value of other env + vars. In the above example, ``DB_PASS`` must be defined after ``DB_USER``. + Moreover, if you define multiple ``.env`` files and put ``DB_PASS`` first, + its value will depend on the ``DB_USER`` value defined in other files + instead of the value defined in this file. + +Define a default value in case the environment variable is not set: + +.. code-block:: bash + + DB_USER= + DB_PASS=${DB_USER:-root}pass # results in DB_PASS=rootpass + +.. versionadded:: 4.4 + + The support for default values has been introduced in Symfony 4.4. + +Embed commands via ``$()`` (not supported on Windows): + +.. code-block:: bash + + START_TIME=$(date) + +.. caution:: + + Using ``$()`` might not work depending on your shell. + +.. tip:: + + As a ``.env`` file is a regular shell script, you can ``source`` it in + your own shell scripts: + + .. code-block:: terminal + + $ source .env + .. _configuration-multiple-env-files: Overriding Environment Values via .env.local diff --git a/controller/error_pages.rst b/controller/error_pages.rst index 2035067a43b..1b05c2745c4 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -125,9 +125,8 @@ as this is very likely to expose sensitive data. .. tip:: - PHP errors are turned into exceptions as well by default, so you can also access these - error details using ``exception``. For more on this see - :ref:`Turning PHP Errors into Exceptions ` + PHP errors are turned into exceptions as well by default, so you can also + access these error details using ``exception``. Security & 404 Pages -------------------- diff --git a/introduction/from_flat_php_to_symfony.rst b/introduction/from_flat_php_to_symfony.rst index fdfe7f359af..85b5f3612d4 100644 --- a/introduction/from_flat_php_to_symfony.rst +++ b/introduction/from_flat_php_to_symfony.rst @@ -243,8 +243,7 @@ the ``templates/layout.php``: You now have a setup that will allow you to reuse the layout. Unfortunately, to accomplish this, you're forced to use a few ugly PHP functions (``ob_start()``, ``ob_get_clean()``) in the template. Symfony -solves this using a :doc:`Templating ` component. -You'll see it in action shortly. +solves this using a `Templating`_ component. You'll see it in action shortly. Adding a Blog "show" Page ------------------------- @@ -683,7 +682,7 @@ migrating the blog from flat PHP to Symfony has improved your life: :doc:`routing `, or rendering :doc:`controllers `; * Symfony gives you **access to open source tools** such as `Doctrine`_ and the - :doc:`Templating `, + `Templating`_, :doc:`Security `, :doc:`Form `, `Validator`_ and `Translation`_ components (to name @@ -703,6 +702,7 @@ A good selection of `Symfony community tools`_ can be found on GitHub. .. _`Model-View-Controller`: https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller .. _`Doctrine`: https://www.doctrine-project.org/ +.. _Templating: https://github.com/symfony/templating .. _Translation: https://github.com/symfony/translation .. _`Composer`: https://getcomposer.org .. _`download Composer`: https://getcomposer.org/download/ diff --git a/web_link.rst b/web_link.rst index 9a35230b8db..1c802a518da 100644 --- a/web_link.rst +++ b/web_link.rst @@ -4,7 +4,7 @@ Asset Preloading and Resource Hints with HTTP/2 and WebLink =========================================================== -Symfony provides native support (via the :doc:`WebLink component `) +Symfony provides native support (via the `WebLink`_ component) for managing ``Link`` HTTP headers, which are the key to improve the application performance when using HTTP/2 and preloading capabilities of modern web browsers. @@ -178,11 +178,7 @@ You can also add links to the HTTP response directly from controllers and servic } } -.. seealso:: - - WebLink can be used :doc:`as a standalone PHP library ` - without requiring the entire Symfony framework. - +.. _`WebLink`: https://github.com/symfony/web-link .. _`HTTP/2 Server Push`: https://tools.ietf.org/html/rfc7540#section-8.2 .. _`Resource Hints`: https://www.w3.org/TR/resource-hints/ .. _`Docker installer and runtime for Symfony`: https://github.com/dunglas/symfony-docker