8000 Merge branch '5.0' · symfony/symfony-docs@d7e293a · GitHub
[go: up one dir, main page]

Skip to content

Commit d7e293a

Browse files
committed
Merge branch '5.0'
* 5.0: [Validator] Removed old versionadded directive [Routing] Removed old versionadded directive Added the docs for the UUID polyfill [Validation] Mention the option to pass stringable objects [Routing] Documented the option to exclude patterns [Monolog] Add a caution note about Symfony Mailer and Monolog [ErrorHandler] Simplified docs
2 parents adb6b35 + a8fc474 commit d7e293a

File tree

5 files changed

+76
-31
lines changed

5 files changed

+76
-31
lines changed

components/error_handler.rst

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@ Installation
2222
Usage
2323
-----
2424

25-
The ErrorHandler component provides several tools to help you debug PHP code:
26-
27-
* An **error handler** that turns PHP errors into exceptions;
28-
* An **exception handler** that turns uncaught PHP exceptions into nice PHP responses;
29-
* A **debug class loader** that provides better errors when a class is not found.
30-
25+
The ErrorHandler component provides several tools to help you debug PHP code.
3126
Call this method (e.g. in your :ref:`front controller <architecture-front-controller>`)
32-
to enable all these features in your application::
27+
to enable all of them in your application::
3328

3429
// public/index.php
3530
use Symfony\Component\ErrorHandler\Debug;
@@ -52,9 +47,10 @@ Turning PHP Errors into Exceptions
5247
----------------------------------
5348

5449
The :class:`Symfony\\Component\\ErrorHandler\\ErrorHandler` class catches PHP
55-
errors and turns them into PHP's :phpclass:`ErrorException` objects, except for
56-
fatal PHP errors, which are turned into Symfony's
57-
:class:`Symfony\\Component\\ErrorHandler\\Exception\\FatalErrorException` objects.
50+
errors and uncaught PHP exceptions and turns them into PHP's
51+
:phpclass:`ErrorException` objects, except for fatal PHP errors, which are
52+
turned into Symfony's :class:`Symfony\\Component\\ErrorHandler\\Exception\\FatalErrorException`
53+
objects.
5854

5955
If the application uses the FrameworkBundle, this error handler is enabled by
6056
default in the :ref:`production environment <configuration-environments>`
@@ -120,26 +116,6 @@ wrap several function calls inside an anonymous function::
120116
return $data;
121117
});
122118

123-
Debugging Uncaught PHP Exceptions
124-
---------------------------------
125-
126-
The :class:`Symfony\\Component\\ErrorHandler\\ExceptionHandler` class catches
127-
uncaught PHP exceptions and turns them into a nice response, so you can debug
128-
them. It is useful in :ref:`debug mode <debug-mode>` to replace the default
129-
PHP/XDebug output with something prettier and more useful.
130-
131-
If the :doc:`HttpFoundation component </components/http_foundation>` is
132-
available, the handler returns a Symfony's
133-
:class:`Symfony\\Component\\HttpFoundation\\Response` object. Otherwise, it returns
134-
a generic PHP response.
135-
136-
Use the following code (e.g. in your :ref:`front controller <architecture-front-controller>`)
137-
to enable this exception handler::
138-
139-
use Symfony\Component\ErrorHandler\ExceptionHandler;
140-
141-
ExceptionHandler::register();
142-
143119
.. _component-debug-class-loader:
144120

145121
Class Loading Debugger

components/polyfill_uuid.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.. index::
2+
single: Polyfill
3+
single: PHP
4+
single: Components; Polyfill
5+
6+
The Symfony Polyfill / UUID Component
7+
=====================================
8+
9+
This component provides ``uuid_*`` functions to users who run PHP versions
10+
without the UUID extension.
11+
12+
Installation
13+
------------
14+
15+
.. code-block:: terminal
16+
17+
$ composer require symfony/polyfill-uuid
18+
19+
.. include:: /components/require_autoload.rst.inc
20+
21+
Usage
22+
-----
23+
24+
Once this component is installed in your application, you can use the following
25+
functions, no matter if the `PHP UUID extension`_ is installed or not in your
26+
server.
27+
28+
Provided Constants
29+
~~~~~~~~~~~~~~~~~~
30+
31+
* ``UUID_VARIANT_NCS`` (value = 0)
32+
* ``UUID_VARIANT_DCE`` (value = 1)
33+
* ``UUID_VARIANT_MICROSOFT`` (value = 2)
34+
* ``UUID_VARIANT_OTHER`` (value = 3)
35+
* ``UUID_TYPE_DEFAULT`` (value = 0)
36+
* ``UUID_TYPE_TIME`` (value = 1)
37+
* ``UUID_TYPE_DCE`` (value = 4)
38+
* ``UUID_TYPE_NAME`` (value = 1)
39+
* ``UUID_TYPE_RANDOM`` (value = 4)
40+
* ``UUID_TYPE_NULL`` (value = -1)
41+
* ``UUID_TYPE_INVALID`` (value = -42)
42+
43+
Provided Functions
44+
~~~~~~~~~~~~~~~~~~
45+
46+
* :phpfunction:`uuid_create`
47+
* :phpfunction:`uuid_is_valid`
48+
* :phpfunction:`uuid_compare`
49+
* :phpfunction:`uuid_is_null`
50+
* :phpfunction:`uuid_type`
51+
* :phpfunction:`uuid_variant`
52+
* :phpfunction:`uuid_time`
53+
* :phpfunction:`uuid_mac`
54+
* :phpfunction:`uuid_parse`
55+
* :phpfunction:`uuid_unparse`
56+
57+
.. _`PHP UUID extension`: https://pecl.php.net/package/uuid

logging/monolog_email.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
How to Configure Monolog to Email Errors
55
========================================
66

7+
.. caution::
8+
9+
This feature is not compatible yet with the new :doc:`Symfony mailer </mailer>`,
10+
so it requires using SwiftMailer.
11+
712
`Monolog`_ can be configured to send an email when an error occurs with an
813
application. The configuration for this requires a few nested handlers
914
in order to avoid receiving too many emails. This configuration looks

routing.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,8 @@ the common configuration using options when importing the routes.
11651165
# An imported route with an empty URL will become "/blog/"
11661166
# Uncomment this option to make that URL "/blog" instead
11671167
# trailing_slash_on_root: false
1168+
# you can optionally exclude some files/subdirectories when loading annotations
1169+
# exclude: '../src/Controller/{DebugEmailController}.php'
11681170
11691171
.. code-block:: xml
11701172
@@ -1178,11 +1180,13 @@ the common configuration using options when importing the routes.
11781180
<!--
11791181
the 'prefix' value is added to the beginning of all imported route URLs
11801182
the 'name-prefix' value is added to the beginning of all imported route names
1183+
the 'exclude' option defines the files or subdirectories ignored when loading annotations
11811184
-->
11821185
<import resource="../src/Controller/"
11831186
type="annotation"
11841187
prefix="/blog"
1185-
name-prefix="blog_">
1188+
name-prefix="blog_"
1189+
exclude="../src/Controller/{DebugEmailController}.php">
11861190
<!-- these requirements are added to all imported routes -->
11871191
<requirement key="_locale">en|es|fr</requirement>
11881192
</import>
@@ -1202,6 +1206,8 @@ the common configuration using options when importing the routes.
12021206
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
12031207
12041208
return function (RoutingConfigurator $routes) {
1209+
// use the optional fifth argument of import() to exclude some files
1210+
// or subdirectories when loading annotations
12051211
$routes->import('../src/Controller/', 'annotation')
12061212
// this is added to the beginning of all imported route URLs
12071213
->prefix('/blog')

validation/custom_constraint.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ The validator class is also simple, and only has one required method ``validate(
8585
}
8686

8787
if (!preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) {
88+
// the argument must be a string or an object implementing __toString()
8889
$this->context->buildViolation($constraint->message)
8990
->setParameter('{{ string }}', $value)
9091
->addViolation();

0 commit comments

Comments
 (0)
0