NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How can PhpED debugger be used to debug script which uses Do


Joined: 27 Nov 2009
Posts: 68
Reply with quote
Edit. I just noticed that subject line get's truncated. The title should have been: How can PhpED debugger be used to debug script which uses Doctrine

PhpED is configured where the root directory is /var/www/testapp, and within this directory, I have the typical public and src directory as well directory /var/www/testapp/var/doctrine/proxy which contains proxy files created by Doctrine. Within my application, I have the following method.

Code:
<?php
namespace Michael\Testapp\Api\Point;
class PointService
{
    public function index(array $params=[]):array {
        syslog(LOG_INFO, 'Before $account=$this->account');
        $account=$this->account;
        syslog(LOG_INFO, 'Before $points=$account->getPoints()');
        $points=$account->getPoints();
        syslog(LOG_INFO, 'Before $points->getValues()');
        $pointValues=$points->getValues();
        syslog(LOG_INFO, 'After $points->getValues()');
        return $pointValues;
    }
}


When I run index.php which eventually calls this method from either Apache or using PhpED's Run, I get the below results.

Code:
Mar 13 16:39:53 Devserver PublicAPI[59900]: Before $account=$this->account
Mar 13 16:39:53 Devserver PublicAPI[59900]: Before $points=$account->getPoints()
Mar 13 16:39:53 Devserver PublicAPI[59900]: Before $points->getValues()
Mar 13 16:39:53 Devserver PublicAPI[59900]: After $points->getValues()


But if I run the same index.php using PhpED's debugger, I witness:

Code:
Mar 13 16:46:50 Devserver PublicAPI[59900]: Before $account=$this->account
Mar 13 16:46:54 Devserver PublicAPI[59900]: Before $points=$account->getPoints()


PhpED's local window shows $this->account as being: object(Proxy\__CG__\Michael\Testapp\Domain\Entity\Account\Account) and a partial copy is below. From this point on, all code is Doctrine and not mine. I am able to trace the code all the way to when it calls \Doctrine\ORM\Proxy\ProxyFactory::createInitializer() and it ends without errors.

Code:
<?php

namespace Proxy\__CG__\Michael\Testapp\Domain\Entity\Account;

/**
 * DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
 */
class Account extends \Michael\Testapp\Domain\Entity\Account\Account implements \Doctrine\ORM\Proxy\Proxy
{
    public function getPoints()
    {

        $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPoints', []);

        return parent::getPoints();
    }
}


How can PhpED debugger be used to debug script which uses Doctrine?


Last edited by NotionCommotion on Wed Mar 20, 2019 5:48 am; edited 1 time in total
View user's profileFind all posts by NotionCommotionSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7957
Reply with quote
I'm not sure how "PhpEd Debugger" can be compared with Apache. PhpED IDE can work with a) local or remote PHP CLI directly or b) SRV, bundled web server or c) local or remote Apache or any other web server capable of running php. So if you mean you didn't succeed running your project with SRV, you can try Apache. In order to do this you may want to create project and proceed with project settings Wizard.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 27 Nov 2009
Posts: 68
Reply with quote
Hi dmitri,

I just noticed that my subject title was truncated on my original post which might have caused some confusion. I have no problems using PhpED most of the time and think it is great, and typically use the remote web server configuration. The only small issue I have with this option is that it doesn't immediately allow me to debug API's which consume PUT and DELETE requests. I expect the CLI configuration will meet this need, however, another great option is to create a small web page which has a php extension (even if it contains no PHP) and a little Javascript to make a request, and the API PHP script can be followed using the debugger just like any other script.

It is only when the API script uses Doctrine that I am experiencing issues. When using the PhpED debugger, the initial entry point file is executed, my routing scripts are executed, Doctrine is queries, but then when when returning the results, the script just mysterious ends without error. I think it has something to do with Doctrine's use of proxies and/or cache, but am not sure.

Any recommendations how to use the PhpED debugger for scripts which utilize Doctrine?

Thanks
View user's profileFind all posts by NotionCommotionSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7957
Reply with quote
I know I should have asked that in the first post but still it's better later than never. Are you running the latest product with the latest version of the debugger? 19106 & 9.1.9 at the moment. If not, please update them first.
Then, proceed with project settings wizard and make sure that there are no detected issue and no warnings in the output.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 27 Nov 2009
Posts: 68
Reply with quote
Much better! Previously I was almost current but one back. What is funny, however, is if I add a breakpoint on the last line of code, it quickly logs to syslog but does not stop on the breakpoint until about 14 seconds later. And if I put the breakpoint on the second to last line of code, it will not break until 14 seconds later even though with the breakpoint on the other line it just took a few microseconds. Not a show stopper but just curious.

When things like this happen which don't seem right but doesn't result in Apache error logs, is there a PhpED generated log which might give clues?

Code:
    public function index(array $params=[]):array {
        $time=microtime(true);
        syslog(LOG_INFO, 'Before $account=$this->account: '.(microtime(true) - $time));
        $account=$this->account;
        syslog(LOG_INFO, 'Before $points=$account->getPoints(): '.(microtime(true) - $time));
        $points=$account->getPoints();
        syslog(LOG_INFO, 'Before $points->getValues(): '.(microtime(true) - $time));
        $pointValues=$points->getValues();
        syslog(LOG_INFO, 'After $points->getValues(): '.(microtime(true) - $time));  /* breakpoint on this line */
        return $pointValues; /* or breakpoint on this line */
    }

Quote:
Mar 21 13:31:21 Devserver PublicAPI[39906]: Before $account=$this->account: 2.8610229492188E-6
Mar 21 13:31:21 Devserver PublicAPI[39906]: Before $points=$account->getPoints(): 6.103515625E-5
Mar 21 13:31:21 Devserver PublicAPI[39906]: Before $points->getValues(): 0.021091938018799
Mar 21 13:31:21 Devserver PublicAPI[39906]: After $points->getValues(): 0.17014288902283
View user's profileFind all posts by NotionCommotionSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7957
Reply with quote
give php profiler built in the IDE a try

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
How can PhpED debugger be used to debug script which uses Do
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic