Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
e6775d74
Commit
e6775d74
authored
Feb 26, 2018
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed docs
parent
684812b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
doc/usage.rst
doc/usage.rst
+13
-5
No files found.
doc/usage.rst
View file @
e6775d74
...
...
@@ -516,12 +516,20 @@ setting a more specific type hint for the Closure argument::
As Silex ensures that the Response status code is set to the most
appropriate one depending on the exception, setting the status on the
response alone won't work. If you want to overwrite the status code
of the exception response, which you should not without a good reason, call
response alone won't work.
If you want to overwrite the status code, which you should not without a
good reason, set the ``X-Status-Code`` header (on Symfony until version
3.2)::
return new Response('Error', 404 /* ignored */, array('X-Status-Code' => 200));
As of Symfony 3.3, call
``GetResponseForExceptionEvent::allowCustomResponseCode()`` first and then
then set the status code on the response as normal. The kernel will
now use your status code when sending the response to the client.
The ``GetResponseForExceptionEvent`` is passed to the error callback as a 4th parameter::
then set the status code on the response as normal. The kernel will now use
your status code when sending the response to the client. The
``GetResponseForExceptionEvent`` is passed to the error callback as a 4th
parameter::
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment