How to make xdebug work with espocrm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • goodwill
    Junior Member
    • Feb 2020
    • 28

    How to make xdebug work with espocrm

    Hi there ,
    I am trying to develop an extension,
    I'm trying to make xdebug work with Espocrm but I have had no luck so far,

    my debug config is

    Code:
    xdebug.mode = debug
    xdebug.start_with_request = yes
    and my vscode config is

    Code:
    {
        "version": "0.2.0",
           "configurations": [
             {
                "name": "Listen for Xdebug",
                "type": "php",
                "request": "launch",
                "port": 9003,
             }
          ]
    }
    ​​

    I can debug any other project just like this, but when I try to use it with Espocrm I can see call stack but my ide doesn't stop at breakpoints
    There is no error in my xdebug and apache log file

    I have enabled isDeveloperMode and useCache is false

    Could someone share with me a working config, what am I doing wrong

    Thanks in advance
  • goodwill
    Junior Member
    • Feb 2020
    • 28

    #2
    Seems like the problem is related to path mapping, seriously could use some advice
    I have struggled with this problem for the past 2 days

    Is there a Developer who is using Xdebug, could someone share his/her phpStorm / vsCode (workspace/launcher) config with me ( Path Mapping Part !)

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #3
      If you use ext-template, source files are not executed/interpreted by php. There's a copy step that copies the module files to the site folder from where they are interpreted when you running Espo. Maybe that's the reason.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • goodwill
        Junior Member
        • Feb 2020
        • 28

        #4
        Originally posted by yuri
        If you use ext-template, source files are not executed/interpreted by php. There's a copy step that copies the module files to the site folder from where they are interpreted when you running Espo. Maybe that's the reason.
        That's not the case the problem is when I try to intercept my module requests that go to /public/api/index.php, couldn't get intercepted
        I can't figure it out I did try different pathMappings but no luck

        I'm trying to extend the Tasks API Controller

        Code:
        namespace Espo\Custom\Controllers;
        
        use Espo\Core\Api\Request;
        use Espo\Core\Api\Response;
        
        // ... extend Tasks
        When I try to intercept for example inside
        Code:
        application/Espo/Core/Api/Request.php
        My breakpoint doesn't stop, I thought maybe because the API path has a rewrite rule, but I couldn't figure it out

        Do you set custom path mapping for your project or any custom config?

        I'm kinda old school I prefer stepping into code with a debugger rather than reading documents,
        It's way more effective for me, but I had no luck

        I know Intercepting something like hasQueryParam going to fire like crazy since it's getting called many times over
        But I like to watch how everything works internally at least once so I could be more effective and prevent reading RAW code / Documents / Trial and Error

        Edited
        Oh I just saw you are the man behind the wheel
        Dude, you are one awesome fella


        Can I suggest some documentation on an advanced development environment / CI | CD
        I could help write up some technical documentation If I could figure out some startup hurdles like this debugging problem
        I'm quite experienced in DevOps ( especially Docker)

        I could create a template ( composer ) for development with remote debugging and integrated ext-template cli, demo data, etc
        Last edited by goodwill; 06-26-2023, 05:24 PM.

        Comment

        • yuri
          Member
          • Mar 2014
          • 8440

          #5
          Hi,

          I must admit I don't use Xdebug at the moment Configuration process is so debilitating (and I work from different PCs) and everything works so much slower. Last time I tried to configure PHPStorm + Xdebug I failed, could not afford myself spend more time on it. I should try again maybe.

          I find that I need to debug something in PHP not that often. Might be because I know Espo codebase enough and static analysis catches a lot of issues before I need to debug.


          > Can I suggest some documentation

          Maybe would be helpful. Not sure what do you mean though. Docker file + docker compose for developer environment?​ We have the repository https://github.com/tmachyshyn/espocr...nt/tree/master with basic environment setups.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

        • yuri
          Member
          • Mar 2014
          • 8440

          #6
          The API processing is not that complicated. You can check the route file application/Espo/Resources/routes.json. Basic CRUD requests are going to Espo\Core\Controllers\RecordBase. Other request entry points can be obtained from the route file.

          After the Record controller, the CRUD requests are following to Espo\Core\Record\Service. Which does needed operations and returns response data.
          Last edited by yuri; 06-27-2023, 08:21 AM.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • goodwill
            Junior Member
            • Feb 2020
            • 28

            #7
            Thank you so much for the tips and help
            When you have a lot of throughput in a platform with loads of async code it is pretty useful, especially for understanding the code
            Since you are the Code Codebase literally, you don't need it <3

            I will try to figure it out and document it, maybe you gave it a shot

            Comment


            • esforim
              esforim commented
              Editing a comment
              yuri recommend some IDE which will help with this problem. Personally I don't code so I never noted it down which IDE.

            • goodwill
              goodwill commented
              Editing a comment
              esforim I think he is using PHPStorm, you can see in Github repo .idea folder, he is putting more effort into setting up the workspace in PHPStorm than VSCode ( Since VSCode folder doesn't have many configurations ), I will try to put some time into setting up some configuration options for VSCode too
          Working...