fabfuel / prophiler

PHP Profiler & Developer Toolbar (built for Phalcon)
http://prophiler.fabfuel.de
Other
443 stars 54 forks source link

Update db plugin to require generic abstract db adapter #83

Open Caffe1neAdd1ct opened 4 years ago

Caffe1neAdd1ct commented 4 years ago

Phalcon 4 compatibility

Fixes the following error:

TypeError: Argument 2 passed to Fabfuel\Prophiler\Plugin\Phalcon\Db\AdapterPlugin::beforeQuery() must be an instance of Phalcon\Db\Adapter, instance of Phalcon\Db\Adapter\Pdo\Mysql given

Once fixed the toolbar seems to be functioning fine when initialised as follows:

$profiler = new \Fabfuel\Prophiler\Profiler();
$di->setShared('profiler', $profiler);

$profiler->addAggregator(new \Fabfuel\Prophiler\Aggregator\Database\QueryAggregator());
$profiler->addAggregator(new \Fabfuel\Prophiler\Aggregator\Cache\CacheAggregator());

$pluginManager = new \Fabfuel\Prophiler\Plugin\Manager\Phalcon($profiler);
$pluginManager->register();

image

Queries are being logged, request info is available and timeline/memory/etc are being displayed. Not a full compatibility test but seems to be mostly working.

fabfuel commented 4 years ago

Thanks @Caffe1neAdd1ct!

I have not worked with Phalcon a while. Would you have time to check the build error in Travis CI?

Best Fabian

Caffe1neAdd1ct commented 4 years ago

Hi @fabfuel

I'll have a look when time permits, however this will need a Phalcon 4 build which would in turn need a few other build requirements:

Here are my notes from the latest install on arch linux:

Download zephir.phar wget https://github.com/phalcon/zephir/releases/download/0.12.19/zephir.phar

Compile PSR git clone https://github.com/jbboehr/php-psr.git cd php-psr phpize ./configure --with-php-config=/usr/bin/php-config sudo make install sudo echo /etc/php/conf.d/psr.ini

extension=psr.so

Compile Zephir Parser pacman -Ss re2c git clone git://github.com/phalcon/php-zephir-parser.git cd php-zephir-parser phpize ./configure --with-php-config=/usr/bin/php-config sudo make install sudo vim /etc/php/conf.d/zephir_parser.ini

[Zephir Parser]
extension=zephir_parser.so

Compile Phalcon git clone --depth=1 "git://github.com/phalcon/cphalcon.git" cd cphalcon git fetch --all --tags git checkout tags/v4.0.6 cd ../cphalcon php ../zephir.phar fullclean php ../zephir.phar build vim /etc/php/conf.d/phalcon.ini

extension=phalcon.so
Caffe1neAdd1ct commented 4 years ago

Also i've no idea on the Scrutinizer error:

https://api.bitbucket.org/1.0/repositories/fabfuel/mongo/tags

{"type": "error", "error": {"message": "Resource removed", "detail": "This API is no longer supported.\n\nFor information about its removal, please refer to the deprecation notice at: https://developer.atlassian.com/cloud/bitbucket/deprecation-notice-v1-apis/"}}

Change to

https://api.bitbucket.org/2.0/repositories/fabfuel/mongo/refs/tags

Guessing this is being caused by an out of date version of Composer... they moved from bitbucket api v1 in about v1.8.4

Caffe1neAdd1ct commented 4 years ago

So i think the conclusion here is to support Phalcon 4 we to fix the build and upgrade the composer phar being used with a simple composer self-update included in the build.

fabfuel commented 4 years ago

Great, thanks! I will have a look at the Scrutinizer issue

iamveecee commented 12 months ago

I also faced the same issue. The purposed solution by @Caffe1neAdd1ct is correct. @fabfuel Could you please merge it.

Thanks