Break point in VS Code. Cannot find classes in Laravel? [Fixed] [Mac]

Break point in VS Code. Cannot find classes in Laravel? [Fixed] [Mac]


Break point is something I really love. Using it in Xcode or other IDE is easy. No setup required. But if you want to use break point in laravel or php based framework, you might be wondering how to use break point. Well, I will share what I know today with you regarding break points which will focus on

  • How to setup XDebug
  • How to setup environment setting to run break point
  • How to actually use break point which can is called either while browsing or if you are testing apis.

Well, it seems, there is not so much issue in windows platform. I see people facing problem is Mac. So, today I will show you steps for Mac only. If you need windows based solution, let me know. Please follow these steps.

  • Install Xdebug through PECL
    • Command: pecl install xdebug
  • Search current php.ini file
    • Command: php --ini
  • Copy the path url for Loaded Configuration File:
    • Eg: /usr/local/etc/php/7.4/php.ini
  • Now open that line in sublime if you have else any app you are using.
    • Command: subl /usr/local/etc/php/7.4/php.ini
  • At the top of php.ini file, add these lines of codes
zend_extension = ""
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
  • Save php.ini file and close it. You no long need it.
  • [1]Now open VS Code and select on Run button with bug icon.
  • [2]Select gear icon and select php to create lunch.json file.
  • Open launch.json file and override code with following one.
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit:
    "version": "0.2.0",
    "configurations": [
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "localSourceRoot": "http://localhost:post/project_name/" // or http://project-name.test if using valet.
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000

Now add break points on your methods where ever you want. And whenever the method is called, the execution is paused and you can do some advance debugging.

And that’s all. I hope this blog is easy and helpful. I was struggling to setup in my mac. So, I made this to make it easy to use break point which I personally think is great tool which you should use for testing and debugging purpose. If you have any issue after following my steps please let me know. I will be happy to reply you.

Thank you.

Leave a Reply