Skip to content

Updated the profiler/* articles to Symfony 4 #8685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions profiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Profiler

.. toctree::
:maxdepth: 1
:glob:

profiler/*
profiler/data_collector
profiler/profiling_data
profiler/matchers
profiler/storage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the order - since we can control the order with this method, let's put the best ones first!

32 changes: 11 additions & 21 deletions profiler/data_collector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ block and set the value of two variables called ``icon`` and ``text``:
{% block toolbar %}
{% set icon %}
{# this is the content displayed as a panel in the toolbar #}
<span class="icon"><img src="..." alt=""/></span>
<span class="sf-toolbar-status">Request</span>
<svg xmlns="http://www.w3.org/2000/svg"> ... </svg>
<span class="sf-toolbar-value">Request</span>
{% endset %}

{% set text %}
Expand All @@ -147,23 +147,15 @@ block and set the value of two variables called ``icon`` and ``text``:

.. tip::

Built-in collector templates define all their images as embedded base64-encoded
images. This makes them work everywhere without having to mess with web assets
links:

.. code-block:: html

<img src="data:image/png;base64,..." />

Another solution is to define the images as SVG files. In addition to being
resolution-independent, these images can be easily embedded in the Twig
template or included from an external file to reuse them in several templates:
Built-in collector templates define all their images as embedded SVG files.
This makes them work everywhere without having to mess with web assets links:

.. code-block:: twig

{{ include('data_collector/icon.svg') }}

You are encouraged to use the latter technique for your own toolbar panels.
{% set icon %}
{{ include('data_collector/icon.svg') }}
{# ... #}
{% endset %}

If the toolbar panel includes extended web profiler information, the Twig template
must also define additional blocks:
Expand All @@ -174,8 +166,7 @@ must also define additional blocks:

{% block toolbar %}
{% set icon %}
<span class="icon"><img src="..." alt=""/></span>
<span class="sf-toolbar-status">Request</span>
{# ... #}
{% endset %}

{% set text %}
Expand Down Expand Up @@ -275,6 +266,5 @@ to specify a tag that contains the template:
))
;

The position of each panel in the toolbar is determined by the priority defined
by each collector. Most built-in collectors use ``255`` as their priority. If you
want your collector to be displayed before them, use a higher value (like 300).
The position of each panel in the toolbar is determined by the collector priority
(the higher the priority, the earlier the panel is displayed in the toolbar).
11 changes: 5 additions & 6 deletions profiler/profiling_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Using this token, you can access the profile of any past response thanks to the
:method:`Symfony\\Component\\HttpKernel\\Profiler\\Profiler::loadProfile` method::

$token = $response->headers->get('X-Debug-Token');
$profile = $container->get('profiler')->loadProfile($token);
$profile = $profiler->loadProfile($token);

.. tip::

Expand All @@ -34,14 +34,13 @@ The ``profiler`` service also provides the
look for tokens based on some criteria::

// get the latest 10 tokens
$tokens = $container->get('profiler')->find('', '', 10, '', '', '');
$tokens = $profiler->find('', '', 10, '', '', '');

// get the latest 10 tokens for all URL containing /admin/
$tokens = $container->get('profiler')->find('', '/admin/', 10, '', '', '');
$tokens = $profiler->find('', '/admin/', 10, '', '', '');

// get the latest 10 tokens for local POST requests
$tokens = $container->get('profiler')->find('127.0.0.1', '', 10, 'POST', '', '');
$tokens = $profiler->find('127.0.0.1', '', 10, 'POST', '', '');

// get the latest 10 tokens for requests that happened between 2 and 4 days ago
$tokens = $container->get('profiler')
->find('', '', 10, '', '4 days ago', '2 days ago');
$tokens = $profiler->find('', '', 10, '', '4 days ago', '2 days ago');
12 changes: 4 additions & 8 deletions profiler/storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@
Switching the Profiler Storage
==============================

In Symfony versions prior to 3.0, profiles could be stored in files, databases,
services like Redis and Memcache, etc. Starting from Symfony 3.0, the only storage
mechanism with built-in support is the filesystem.

By default the profile stores the collected data in the ``%kernel.cache_dir%/profiler/``
The profiler stores the collected data in the ``%kernel.cache_dir%/profiler/``
directory. If you want to use another location to store the profiles, define the
``dsn`` option of the ``framework.profiler``:

.. configuration-block::

.. code-block:: yaml

# app/config/config.yml
# config/packages/dev/web_profiler.yaml
framework:
profiler:
dsn: 'file:/tmp/symfony/profiler'

.. code-block:: xml

<!-- app/config/config.xml -->
<!-- config/packages/dev/web_profiler.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -40,7 +36,7 @@ directory. If you want to use another location to store the profiles, define the

.. code-block:: php

// app/config/config.php
// config/packages/dev/web_profiler.php

// ...
$container->loadFromExtension('framework', array(
Expand Down