Skip to content

Extract the profiler to a new component #10374

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

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 8 additions & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ UPGRADE FROM 2.x to 3.0
* The `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass` has been renamed to
`Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass` and moved to the EventDispatcher component.

* The profiler was moved to the HttpProfiler component:

* `Symfony\Component\HttpKernel\DataCollector` -> `Symfony\Component\HttpProfiler\DataCollector`
* `Symfony\Component\HttpKernel\EventDispatcher\ProfilerListener` -> `Symfony\Component\HttpProfiler\EventDispatcher\ProfilerListener`
* `Symfony\Component\HttpKernel\Profiler` -> `Symfony\Component\HttpProfiler\Storage`
* `Symfony\Component\HttpKernel\Profiler\Profiler` -> `Symfony\Component\HttpProfiler\Profiler`
* `Symfony\Component\HttpKernel\Profiler\Profile` -> `Symfony\Component\HttpProfiler\Profile`

### Locale

* The Locale component was removed and replaced by the Intl component.
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpKernel\Client as BaseClient;
use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile;
use Symfony\Component\HttpProfiler\Profile as HttpProfile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\BrowserKit\History;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $

// Choose storage class based on the DSN
$supported = array(
'sqlite' => 'Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage',
'mysql' => 'Symfony\Component\HttpKernel\Profiler\MysqlProfilerStorage',
'file' => 'Symfony\Component\HttpKernel\Profiler\FileProfilerStorage',
'mongodb' => 'Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage',
'memcache' => 'Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage',
'memcached' => 'Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage',
'redis' => 'Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage',
'sqlite' => 'Symfony\Component\HttpProfiler\Storage\SqliteProfilerStorage',
'mysql' => 'Symfony\Component\HttpProfiler\Storage\MysqlProfilerStorage',
'file' => 'Symfony\Component\HttpProfiler\Storage\FileProfilerStorage',
'mongodb' => 'Symfony\Component\HttpProfiler\Storage\MongoDbProfilerStorage',
'memcache' => 'Symfony\Component\HttpProfiler\Storage\MemcacheProfilerStorage',
'memcached' => 'Symfony\Component\HttpProfiler\Storage\MemcachedProfilerStorage',
'redis' => 'Symfony\Component\HttpProfiler\Storage\RedisProfilerStorage',
);
list($class, ) = explode(':', $config['dsn'], 2);
if (!isset($supported[$class])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="profiler.class">Symfony\Component\HttpKernel\Profiler\Profiler</parameter>
<parameter key="profiler_listener.class">Symfony\Component\HttpKernel\EventListener\ProfilerListener</parameter>
<parameter key="profiler.class">Symfony\Component\HttpProfiler\Profiler</parameter>
<parameter key="profiler_listener.class">Symfony\Component\HttpProfiler\EventListener\ProfilerListener</parameter>
</parameters>

<services>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bundle\WebProfilerBundle\Controller;

use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\HttpProfiler\Profiler;
use Symfony\Component\Debug\ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\HttpProfiler\Profiler;
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\HttpProfiler\Profiler;

/**
* RouterController.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Symfony\Bundle\WebProfilerBundle\Profiler;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\HttpProfiler\Profiler;
use Symfony\Component\HttpProfiler\Profile;

/**
* Profiler Templates Manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
use Symfony\Component\HttpProfiler\Profiler;
use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;

/**
* Test for TemplateManager class.
Expand All @@ -27,7 +29,7 @@ class TemplateManagerTest extends TestCase
protected $twigEnvironment;

/**
* @var \Symfony\Component\HttpKernel\Profiler\Profiler
* @var Profiler
*/
protected $profiler;

Expand All @@ -37,7 +39,7 @@ class TemplateManagerTest extends TestCase
protected $profile;

/**
* @var \Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager
* @var TemplateManager
*/
protected $templateManager;

Expand Down Expand Up @@ -153,7 +155,7 @@ protected function mockTwigEnvironment()

protected function mockProfiler()
{
$this->profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
$this->profiler = $this->getMockBuilder('Symfony\Component\HttpProfiler\Profiler')
->disableOriginalConstructor()
->getMock();

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpKernel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
2.5.0
-----

* deprecated all Profiler-related classes (use the HttpProfiler component now)
* deprecated `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass`, use `Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass` instead

2.4.0
Expand Down
230 changes: 2 additions & 228 deletions src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,235 +11,9 @@

namespace Symfony\Component\HttpKernel\DataCollector;

use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* ConfigDataCollector.
*
* @author Fabien Potencier <fabien@symfony.com>
* @deprecated Deprecated in 2.5, to be removed in 3.0. Use the HttpProfiler component instead.
*/
class ConfigDataCollector extends DataCollector
class ConfigDataCollector extends \Symfony\Component\HttpProfiler\DataCollector\ConfigDataCollector
Copy link
Member

Choose a reason for hiding this comment

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

you should make these deprecated class implement the deprecated DataCollectorInterface as well to provide BC

{
private $kernel;
private $name;
private $version;

/**
* Constructor.
*
* @param string $name The name of the application using the web profiler
* @param string $version The version of the application using the web profiler
*/
public function __construct($name = null, $version = null)
{
$this->name = $name;
$this->version = $version;
}

/**
* Sets the Kernel associated with this Request.
*
* @param KernelInterface $kernel A KernelInterface instance
*/
public function setKernel(KernelInterface $kernel = null)
{
$this->kernel = $kernel;
}

/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = array(
'app_name' => $this->name,
'app_version' => $this->version,
'token' => $response->headers->get('X-Debug-Token'),
'symfony_version' => Kernel::VERSION,
'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
'php_version' => PHP_VERSION,
'xdebug_enabled' => extension_loaded('xdebug'),
'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'),
'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'),
'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'),
'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'),
'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'),
'bundles' => array(),
'sapi_name' => php_sapi_name()
);

if (isset($this->kernel)) {
foreach ($this->kernel->getBundles() as $name => $bundle) {
$this->data['bundles'][$name] = $bundle->getPath();
}
}
}

public function getApplicationName()
{
return $this->data['app_name'];
}

public function getApplicationVersion()
{
return $this->data['app_version'];
}

/**
* Gets the token.
*
* @return string The token
*/
public function getToken()
{
return $this->data['token'];
}

/**
* Gets the Symfony version.
*
* @return string The Symfony version
*/
public function getSymfonyVersion()
{
return $this->data['symfony_version'];
}

/**
* Gets the PHP version.
*
* @return string The PHP version
*/
public function getPhpVersion()
{
return $this->data['php_version'];
}

/**
* Gets the application name.
*
* @return string The application name
*/
public function getAppName()
{
return $this->data['name'];
}

/**
* Gets the environment.
*
* @return string The environment
*/
public function getEnv()
{
return $this->data['env'];
}

/**
* Returns true if the debug is enabled.
*
* @return Boolean true if debug is enabled, false otherwise
*/
public function isDebug()
{
return $this->data['debug'];
}

/**
* Returns true if the XDebug is enabled.
*
* @return Boolean true if XDebug is enabled, false otherwise
*/
public function hasXDebug()
{
return $this->data['xdebug_enabled'];
}

/**
* Returns true if EAccelerator is enabled.
*
* @return Boolean true if EAccelerator is enabled, false otherwise
*/
public function hasEAccelerator()
{
return $this->data['eaccel_enabled'];
}

/**
* Returns true if APC is enabled.
*
* @return Boolean true if APC is enabled, false otherwise
*/
public function hasApc()
{
return $this->data['apc_enabled'];
}

/**
* Returns true if Zend OPcache is enabled
*
* @return Boolean true if Zend OPcache is enabled, false otherwise
*/
public function hasZendOpcache()
{
return $this->data['zend_opcache_enabled'];
}

/**
* Returns true if XCache is enabled.
*
* @return Boolean true if XCache is enabled, false otherwise
*/
public function hasXCache()
{
return $this->data['xcache_enabled'];
}

/**
* Returns true if WinCache is enabled.
*
* @return Boolean true if WinCache is enabled, false otherwise
*/
public function hasWinCache()
{
return $this->data['wincache_enabled'];
}

/**
* Returns true if any accelerator is enabled.
*
* @return Boolean true if any accelerator is enabled, false otherwise
*/
public function hasAccelerator()
{
return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache();
}

public function getBundles()
{
return $this->data['bundles'];
}

/**
* Gets the PHP SAPI name.
*
* @return string The environment
*/
public function getSapiName()
{
return $this->data['sapi_name'];
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'config';
}
}
Loading