Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't using Visual Code to debug in Laravel project

I was config success to debug in PHP on VSCode.

My problem is when I run the project it always errors at the function:

protected function getJsonPayload($payload)
{
    $payload = json_decode(base64_decode($payload), true);

    // If the payload is not valid JSON or does not have the proper keys set we will
    // assume it is invalid and bail out of the routine since we will not be able
    // to decrypt the given value. We'll also check the MAC for this encryption.
    if (! $this->validPayload($payload)) {
        throw new DecryptException('The payload is invalid.');
    }

    if (! $this->validMac($payload)) {
        throw new DecryptException('The MAC is invalid.');
    }

    return $payload;
}

... from file: /srv/http/laravelproject/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php

I can't debug to breakpoint I was set.

Gif screen record: http://i.imgur.com/6pNkoHe.gif

like image 440
Ave Avatar asked Jun 21 '17 07:06

Ave


People also ask

Why is my debugger not working in VS Code?

The most common problem is that you did not set up launch.json or there is a syntax error in that file. Alternatively, you might need to open a folder, since no-folder debugging does not support launch configurations.

How do I enable debugging in Laravel?

Enable or disable debug mode using app. Open the app. php file located in your config/app. php laravel project. Search for debug key and change true to enable debug mode and false for disabling debug mode default it will show false.


1 Answers

Had the same issue when using Docker with VsCode and xDebug in Laravel.

For anyone interested in a different approach (since Laravel 5.6 there is no optimize command anymore)

Just add the ignore section to your launch.json config.

{
   "name": "Listen for XDebug",
   "type": "php",
   "request": "launch",
   "port": 9000,
   "pathMappings": {
       "/var/www/html": "${workspaceRoot}",
    },
    // add this
    "ignore": [
        "**/vendor/**/*.php"
    ]
},

Solved the issue for me.

Got this from Docker Github Repo

like image 97
Krishan König Avatar answered Oct 12 '22 13:10

Krishan König