snowair / phalcon-debugbar

A powerful debug and profilers tool for the Phalcon Framework
MIT License
163 stars 49 forks source link

does not work with Phalcon version 4.0.0 #63

Open zak-wojtek77 opened 4 years ago

zak-wojtek77 commented 4 years ago

Does not work with Phalcon version 4.0.0.

snowair commented 4 years ago

Sorry, It does not support for 4.x now.

casparjones commented 4 years ago

Are there plans to upgrade the debugbar for phalcon 4.x? I was a big fan of the debugbar and would not gladly give it up. :)

alexbusu commented 4 years ago

@casparjones the Phalcon v4 api (of the common Di services) is slightly changed from v3, so it would not take a huge amount of time to make the phalcon-debugbar compatible with Phalcon 4; feel free to debug and push some adjustments in a PR :)

OrangeTanguine commented 4 years ago

I just change this to stop the fatal error, but there is a lot of change to do ServiceProvider.php - line 184 - $router->handle(); --> $router->handle($_GET['_url'] ?? '/'); How can we debug it ? i have no error...

OrangeTanguine commented 4 years ago

ok, it's working with phalcon 4 now... but i don't know if all functionnality are ok... I'm going to commit or do a diff file :)

OrangeTanguine commented 4 years ago

can you do a branch for it ? one beta v4.0.0 ?

OrangeTanguine commented 4 years ago

poke @snowair :)

ServiceProvider.php Line 184

$router->handle(); $deny_routes = (array)$config->get('deny_routes'); $allow_routes = (array)$config->get('allow_routes');

to

$router->handle($_SERVER["REQUEST_URI"]); $deny_routes = $config->get('deny_routes')->toArray(); $allow_routes = $config->get('allow_routes')->toArray();

PhalconDebugbar.php

Line 20 to 23

use Phalcon\Cache\Backend; use Phalcon\Cache\Multiple; use Phalcon\Db\Adapter; use Phalcon\Db\Adapter\Pdo;

to

use Phalcon\Cache; use Phalcon\Db\Adapter\AbstractAdapter; use Phalcon\Db\Adapter\Pdo\AbstractPdo;

Line 241

if ($this->shouldCollect('doctrine', false) &&!$this->hasCollector('doctrine') && !$this->hasCollector('pdo') ) {

to

if ($this->shouldCollect('doctrine', false) &&!$this->hasCollector('doctrine') && !$this->hasCollector('AbstractPdo') ) {

Line 276

if ( $backend instanceof Multiple || $backend instanceof Backend ) {

to

if ( $backend instanceof Cache ) {

line 602

if( $this->hasCollector('pdo') ){ /* @var Profiler $profiler / $profiler = $this->getCollector('pdo')->getProfiler(); $profiler->handleFailed(); }

to

if( $this->hasCollector('AbstractPdo') ){ /* @var Profiler $profiler / $profiler = $this->getCollector('AbstractPdo')->getProfiler(); $profiler->handleFailed(); }

line 697

$eventsManager->attach('db', function(Event $event, Adapter $db, $params) use (

to

$eventsManager->attach('db', function(Event $event, AbstractAdapter $db, $params) use (

PhalconHttpDriver.php

Line 30

function isSessionStarted() { if ( !$this->session->isStarted() ) { $this->session->start(); } return $this->session->isStarted(); }

to

function isSessionStarted() { if ( !$this->session->exists() ) { $this->session->start(); } return $this->session->exists(); }

Storage/Filesystem.php

Line 23

public function __construct($dirname,$di) { if ( !$di['session']->isStarted() ) { $di['session']->start(); } $sid = $di['session']->getId();

to

public function __construct($dirname,$di) { if ( !$di['session']->exists() ) { $di['session']->start(); } $sid = $di['session']->getId();

Db/Profiler.php

Line 70

public function startProfile($sqlStatement, $sqlVariables = null, $sqlBindTypes = null)

to

public function startProfile($sqlStatement, $sqlVariables = null, $sqlBindTypes = null): \Phalcon\Db\Profiler

Line 172

public function stopProfile()

to

public function stopProfile(): \Phalcon\Db\Profiler

Phalcon\Db\Profiler.php

Line 10

use Phalcon\Db\Adapter;

to

use Phalcon\Db\Adapter\AbstractAdapter;

Phalcon/Cache/Proxy.php

line 9

Phalcon\Cache\Exception

to

Phalcon\Cache\Exception\Exception

remove line 10

use Phalcon\Cache\Frontend\Base64;

line 27

if ( is_object($frontend) && $frontend instanceof Base64 ) {

to (Base64 was deleted. Maybe there is another way to verify if $frontend is Base64)

if ( is_object($frontend)) {

Phalcon/Cache/ProxyTrait.php

line 9

Phalcon\Cache\Exception

to

Phalcon\Cache\Exception\Exception

remove lines 10 and 11

use Phalcon\Cache\Frontend\Base64; use Phalcon\Cache\Frontend\Output;

line 32

if ( is_object($frontend) && $frontend instanceof Base64 ) {

to (Base64 was deleted. Maybe there is another way to verify if $frontend is Base64)

if ( is_object($frontend)) {

comment line 61 to 63

if ( ! $this->_backend->getFrontend() instanceof Output ) { return null; }

to (Output was deleted. Maybe there is another way to verify if $frontend is Output )

line 106 to 110

if ( !$this->_backend->getFrontend() instanceof Output ) { return null; }else{ $content = $this->_backend->getFrontend()->getContent(); }

to

$content = $this->_backend->getFrontend()->getContent();

Phalcon/logger/Adapter/Debugbar.php

Line 11

use Phalcon\Logger\Adapter;

to

use Phalcon\Logger\Adapter\AbstractAdapter;

Line 16

class Debugbar extends Adapter implements AdapterInterface{

to

class Debugbar extends AbstractAdapter implements AdapterInterface{

DataCollector/Formatter.php

Lines 15 and 16

use Phalcon\Validation\Message; use Phalcon\Validation\Message\Group;

to

use Phalcon\Messages\Message; use Phalcon\Messages\Messages;

Line 65

if ( $var instanceof Group ) {

to

if ( $var instanceof Messages) {

Line 87

if ( $messages instanceof Group ) {

to

if ( $messages instanceof Messages ) {

DataCollector/LogsCollector.php

Line 13

use Phalcon\Logger\Adapter;

to

Phalcon\Logger\Adapter\AbstractAdapter;

Line 49

if ( $log instanceof Adapter ) {

to

if ( $log instanceof AbstractAdapter) {

delete line 15

use Phalcon\Logger\Formatter\Syslog;

line 68

if ( is_scalar($message) && $this->_formatter=='syslog' && $formatter = new Syslog ) {

to (Syslog was deleted)

if ( is_scalar($message) && $this->_formatter=='syslog' && $formatter = new Line ) {

delete line 16

use Phalcon\Logger\Multiple;

// TODO : REPLACE THIS PART, Multiple was deleted, I don't know how to replace it for the moment

if ( $log instanceof AbstractAdapter ) { $di->remove('log'); $multiple = new Multiple(); $multiple->push( clone $log ); $multiple->push( $debugbar_loger ); /* @var DI\Service $service / $di->set('log',$multiple); }elseif($log instanceof Multiple){ $log->push( $debugbar_loger ); }elseif( class_exists('Monolog\Logger') && $log instanceof Logger ){ $handler = new \Snowair\Debugbar\Monolog\Handler\Debugbar($this->_debugbar); $log->pushHandler($handler); }

DataCollector/CacheCollector.php

Line 12

use Phalcon\Cache\Backend;

to

use Phalcon\Cache

I think there is all the needed modifications. I don't know if all functionnalities run but the toolbar open.

We don't show queries for the moment, i will update if i fix it

OrangeTanguine commented 4 years ago

So, i failed for queries... in DataCollector\QueryCollector

$succeed = (array)$this->profiler->getProfiles();

return null....

However $this->profiler object contains data, but getProfiles doesn't work... If someone can find the solution... Thks

OrangeTanguine commented 4 years ago

I have found a solution, but it's not clean... \DataCollector\QueryCollector.php

line 31 to 36 replace with

/* @var Item[] $succeed / $succeed = (array)$this->profiler->getProfiles(); $succeed = $tab_profiles["_allProfiles"]; /* @var Item[] $failed / $failed = (array)$this->profiler->getFailedProfiles();

to

$tab_profiles = (array)$this->profiler; /* @var Item[] $succeed / //$succeed = (array)$this->profiler->getProfiles(); $succeed = $tab_profiles["_allProfiles"]; /* @var Item[] $failed / $failed = (array)$this->profiler->getFailedProfiles();

OrangeTanguine commented 4 years ago

i pushed all my modifications to the project...