Compare commits

...

3 Commits

10 changed files with 293 additions and 25 deletions

View File

@ -16,13 +16,20 @@ declare(strict_types=1);
namespace D3\DebugBar\Application\Component;
use D3\DebugBar\Application\Models\Collectors\OxidConfigCollector;
use D3\DebugBar\Application\Models\Collectors\OxidShopCollector;
use D3\DebugBar\Application\Models\Collectors\OxidVersionCollector;
use D3\DebugBar\Application\Models\Collectors\SmartyCollector;
use D3\DebugBar\Application\Models\TimeDataCollectorHandler;
use DebugBar\Bridge\DoctrineCollector;
use DebugBar\Bridge\MonologCollector;
use DebugBar\DataCollector\MemoryCollector;
use DebugBar\DataCollector\MessagesCollector;
use DebugBar\DataCollector\PhpInfoCollector;
use DebugBar\DataCollector\RequestDataCollector;
use DebugBar\DataCollector\TimeDataCollector;
use DebugBar\DebugBar;
use DebugBar\DebugBarException;
use DebugBar\JavascriptRenderer;
use DebugBar\StandardDebugBar;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Logging\DebugStack;
use Monolog\Logger;
@ -35,7 +42,7 @@ use ReflectionException;
class DebugBarComponent extends BaseController
{
/** @var StandardDebugBar */
/** @var DebugBar */
protected $debugBar;
/** @var JavascriptRenderer */
protected $debugBarRenderer;
@ -56,7 +63,7 @@ class DebugBarComponent extends BaseController
parent::__construct();
if (false === isAdmin()) {
$debugbar = new StandardDebugBar();
$debugbar = new DebugBar();
$this->addCollectors($debugbar);
@ -102,6 +109,14 @@ class DebugBarComponent extends BaseController
return new SmartyCollector($smarty);
}
/**
* @return OxidShopCollector
*/
public function getOxidShopCollector(): OxidShopCollector
{
return oxNew(OxidShopCollector::class);
}
/**
* @return OxidConfigCollector
*/
@ -110,6 +125,14 @@ class DebugBarComponent extends BaseController
return oxNew(OxidConfigCollector::class, Registry::getConfig());
}
/**
* @return OxidVersionCollector
*/
public function getOxidVersionCollector(): OxidVersionCollector
{
return oxNew(OxidVersionCollector::class);
}
/**
* @param object $object
* @param string $propName
@ -126,18 +149,28 @@ class DebugBarComponent extends BaseController
}
/**
* @param StandardDebugBar $debugbar
* @param DebugBar $debugbar
* @return void
* @throws DatabaseConnectionException
* @throws DebugBarException
* @throws ReflectionException
*/
public function addCollectors(StandardDebugBar $debugbar): void
public function addCollectors(DebugBar $debugbar): void
{
// add all default collectors except the useless ExceptionCollector
$debugbar->addCollector(new PhpInfoCollector());
$debugbar->addCollector(new MessagesCollector());
$debugbar->addCollector(new RequestDataCollector());
$debugbar->addCollector(new TimeDataCollector());
$debugbar->addCollector(new MemoryCollector());
// add custom collectors
$debugbar->addCollector($this->getOxidShopCollector());
$debugbar->addCollector($this->getOxidConfigCollector());
$debugbar->addCollector($this->getSmartyCollector());
$debugbar->addCollector($this->getMonologCollector());
$debugbar->addCollector($this->getDoctrineCollector());
$debugbar->addCollector($this->getSmartyCollector());
$debugbar->addCollector($this->getOxidConfigCollector());
$debugbar->addCollector($this->getOxidVersionCollector());
}
/**
@ -155,9 +188,9 @@ class DebugBarComponent extends BaseController
}
/**
* @return StandardDebugBar
* @return DebugBar
*/
public function getDebugBar(): StandardDebugBar
public function getDebugBar(): DebugBar
{
return $this->debugBar;
}

View File

@ -128,7 +128,7 @@ class OxidConfigCollector extends DataCollector implements Renderable
: "PhpDebugBar.Widgets.VariableListWidget";
return [
"Configuration" => [
"icon" => "tags",
"icon" => "database",
"widget" => $widget,
"map" => "oxidconfig.vars",
"default" => "{}",

View File

@ -0,0 +1,143 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DebugBar\Application\Models\Collectors;
use Composer\InstalledVersions;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Module\Module;
use OxidEsales\Eshop\Core\ShopVersion;
use OxidEsales\Eshop\Core\Theme;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridgeInterface;
use OxidEsales\Facts\Facts;
class OxidShopCollector extends DataCollector implements Renderable
{
/** @var Config */
protected $config;
/** @var array */
protected $configVars = [];
/**
* @var bool
*/
protected $useHtmlVarDumper = true;
public function __construct()
{
$facts = new Facts();
$theme = new Theme();
$parentThemeId = $theme->getParent() ? $theme->getParent()->getId() : '--';
$moduleList = $this->getInstalledModules();
array_walk(
$moduleList,
function (Module &$module) {
$str = trim(strip_tags($module->getTitle())).' - '.$module->getInfo('version').' ';
$module = $str;
}
);
$this->configVars = [
'Shop Edition:' => $facts->getEdition(),
'Shop Version:' => ShopVersion::getVersion(),
'CE Version:' => InstalledVersions::getVersion('oxid-esales/oxideshop-ce'),
'Theme:' => $theme->getActiveThemeId(),
'Parent Theme:' => $parentThemeId,
'Modules:' => implode(chr(10), $moduleList)
];
}
/**
* @return string
*/
public function getName(): string
{
return 'oxidshop';
}
/**
* @return array
*/
public function collect(): array
{
$data = [];
$vars = $this->configVars;
foreach ($vars as $idx => $var) {
if ($this->isHtmlVarDumperUsed()) {
$data[$idx] = $this->getVarDumper()->renderVar($var);
} else {
$data[$idx] = $this->getDataFormatter()->formatVar($var);
}
}
return ['vars' => $data, 'count' => count($data)];
}
/**
* Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
* rendering.
*
* @return mixed
*/
public function isHtmlVarDumperUsed()
{
return $this->useHtmlVarDumper;
}
/**
* @return array
*/
public function getWidgets(): array
{
$widget = $this->isHtmlVarDumperUsed()
? "PhpDebugBar.Widgets.HtmlVariableListWidget"
: "PhpDebugBar.Widgets.VariableListWidget";
return [
"Shop" => [
"icon" => "shopping-cart",
"widget" => $widget,
"map" => $this->getName().".vars",
"default" => "{}",
],
];
}
protected function getInstalledModules(): array
{
$container = ContainerFactory::getInstance()->getContainer();
$shopConfiguration = $container->get(ShopConfigurationDaoBridgeInterface::class)->get();
$modules = [];
foreach ($shopConfiguration->getModuleConfigurations() as $moduleConfiguration) {
$module = oxNew(Module::class);
$module->load($moduleConfiguration->getId());
$modules[] = $module;
}
usort($modules, function ($a, $b) {
return strcmp($a->getTitle(), $b->getTitle());
});
return $modules;
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DebugBar\Application\Models\Collectors;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use OxidEsales\Eshop\Core\ShopVersion;
use OxidEsales\Eshop\Core\Theme;
use OxidEsales\Facts\Facts;
/**
* Collects info about OXID shop
*/
class OxidVersionCollector extends DataCollector implements Renderable
{
/**
* @return string
*/
public function getName()
{
return 'oxidversion';
}
/**
* @return array
*/
public function collect()
{
$facts = new Facts();
$theme = new Theme();
$parentThemeId = $theme->getParent() ? $theme->getParent()->getId() : '--';
return array(
'version' => $facts->getEdition().' '.ShopVersion::getVersion()
);
}
/**
* {@inheritDoc}
*/
public function getWidgets()
{
$collect = $this->collect();
return [
"oxidversion" => [
"icon" => "shopping-cart",
"tooltip" => 'OXID Version',
"map" => $this->getName().".version",
"default" => ""
],
];
}
}

View File

@ -6,6 +6,7 @@
*
* https://www.d3data.de
*
* @copyright (c) 2016 Dmitry Kosenkov
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
@ -101,12 +102,12 @@ class SmartyCollector extends DataCollector implements Renderable
: "PhpDebugBar.Widgets.VariableListWidget";
return [
"smarty" => [
"icon" => "tags",
"icon" => "file-text",
"widget" => $widget,
"map" => "smarty.vars",
"default" => "{}",
],
"smarty:badge" => [
"smarty:badge" => [
"map" => "smarty.count",
"default" => 0,
],

View File

@ -4,7 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased](https://git.d3data.de/D3Public/DebugBar/compare/1.0.0.0...rel_1.x)
## [Unreleased](https://git.d3data.de/D3Public/DebugBar/compare/1.1.0.0...rel_1.x)
## [1.1.0.0](https://git.d3data.de/D3Public/DebugBar/compare/1.0.0.0...1.1.0.0) - 2022-08-05
### Added
- shop edition and version information directly in the bar
- basic shop informations (edition, version, theme informations) in the shop tab
### Changed
- reorder tabs
- adjust tab icons for small viewports
### removed
- useless exceptions tab
## [1.0.0.0](https://git.d3data.de/D3Public/DebugBar/releases/tag/1.0.0.0) - 2022-07-30
### Added

View File

@ -10,10 +10,11 @@ The debug bar enables the display of relevant debug information in the shop fron
## Table of content
- [Installation](#installation)
- [How to use](#how-to-use)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [License](#license)
- [Further licences and terms of use](#further-licences-and-terms-of-use)
- [Further licenses and terms of use](#further-licenses-and-terms-of-use)
## Installation
@ -39,7 +40,6 @@ Please enter the following section in the `composer.json` of your project:
Open a command line and navigate to the root directory of the shop (parent directory of source and vendor). Execute the following command. Adapt the path details to your installation environment.
```bash
php composer require d3/oxid-debugbar:^1.0
```
@ -50,21 +50,25 @@ Activate the module in Shopadmin under "Extensions -> Modules".
## How to use
__Please note that the DebugBar contains security-relevant information. It should therefore not be activated under any circumstances in a freely accessible installation.__
The DebugBar displays the following tabs:
- Messages
can contain individual debug output. Messages can be set within the PHP code with `debugVar($message)` and corresponds to the OXID function `dumpVar(...)`
can contain individual debug output. The messages can be set within the PHP code with `debugVar($message)` and corresponds to the OXID function `dumpVar(...)`
- Request
shows all information from GET and POST requests, as well as session, cookie and server variables
- Timeline
displays all areas defined with `startProfile` and `stopProfile` with single and summed execution time as well as a waterfall diagram
- Shop
shows basic shop information (edition, versions, theme information)
- Configuration
provides all configuration settings of the shop from database and config files
- Smarty
lists all variables of the template engine that are available on the current shop page
- Monolog
lists all log messages passed to the Monolog Logger
- Database
shows all database queries necessary to generate the current page
- Smarty
lists all Smarty variables available on the current shop page
- Configuration
Provides all configuration settings of the shop (from database and file).
## Changelog

View File

@ -10,6 +10,7 @@ Die Debug Bar ermöglicht die Darstellung relevanter Debuginformationen im Shopf
## Inhaltsverzeichnis
- [Installation](#installation)
- [Verwendung](#verwendung)
- [Changelog](#changelog)
- [Beitragen](#beitragen)
- [Lizenz](#lizenz)
@ -39,7 +40,6 @@ Bitte tragen Sie den folgenden Abschnitt in die `composer.json` Ihres Projektes
Öffnen Sie eine Kommandozeile und navigieren Sie zum Stammverzeichnis des Shops (Elternverzeichnis von source und vendor). Führen Sie den folgenden Befehl aus. Passen Sie die Pfadangaben an Ihre Installationsumgebung an.
```bash
php composer require d3/oxid-debugbar:^1.0
```
@ -50,6 +50,8 @@ Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
## Verwendung
__Bitte beachten Sie, dass die DebugBar sicherheitsrelevante Informationen enthält. Diese sollte daher unter keinen Umständen in einer frei zugänglichen Installation aktiviert sein.__
Die DebugBar stellt folgende Tabs dar:
- Messages
kann individuelle Debugausgaben enthalten. Die Nachrichten können innerhalb des PHP-Codes mit `debugVar($message)` gesetzt werden und entspricht der OXID-Funktion `dumpVar(...)`.
@ -57,14 +59,16 @@ Die DebugBar stellt folgende Tabs dar:
zeigt alle Angaben aus GET- und POST-Requests, sowie Session-, Cookie- und Servervariablen
- Timeline
stellt alle mit `startProfile` und `stopProfile` definierten Bereiche mit einzelner und summierter Ausführungszeit sowie als Wasserfalldiagramm dar
- Shop
zeigt grundlegende Shopinformationen (Edition, Versionen, Themeinformationen)
- Configuration
stellt alle Konfigurationseinstellungen des Shops aus Datenbank und config-Dateien zur Verfügung
- Smarty
listet alle Variablen der Template-Engine, die auf der aktuellen Shopseite zur Verfügung stehen
- Monolog
listet alle an den Monolog Logger übergebenen Lognachrichten
- Database
zeigt alle zur Generierung der aktuellen Seite nötigen Datenbankabfragen
- Smarty
listet alle Smarty-Variablen, die auf der aktuellen Shopseite zur Verfügung stehen
- Configuration
stellt alle Konfigurationseinstellungen des Shops aus Datenbank und Dateien zur Verfügung
## Changelog

5
ToDo.md Normal file
View File

@ -0,0 +1,5 @@
# ToDo
- clear tmp button
- phpinfo() overview
- automatic switch between Smarty and Twig

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 71 KiB