visual-studio-codeterminalenvironment-variableslaragon

Laragon terminal in VSCode with Laragon PATH environment variable


How to use the Laragon terminal in VSCode with Laragon PATH environment variable (on Windows)?

I want to use the Laragon terminal in Visual Studio Code.
I want to use the local Laragon PHP, Composer, MySQL, Node.js, etc. in the terminal.


Solution

    1. Open Laragon, right click > Tools > Path > Manage Path.
    2. Copy everything between the --- Laragon --- and the next section (probably --- User ---).
    3. I also put the three lines starting with C:\\Users\\[YOUR_USERNAME]\\AppData\\ at the start, so the Laragon composer and npm are used instead of the global ones.
    4. Put all the paths on one line (they should be separated by a semicolon), and double all the backslashes.
    5. Open your project settings.json, and add these values:
    "terminal.integrated.shell.windows": "C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\git\\bin\\bash.exe",
    "terminal.integrated.env.windows": {
        "PATH": "[PASTE_THE_PATHS_HERE];${env:PATH}"
    }
    

    The first line makes the Laragon terminal default. The second one makes the terminal use the Laragon paths/binaries.
    6. You can also add the Laragon php path as the language validation executable:

    "php.validate.executablePath": "C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\php\\php-8.0.3-Win32-vs16-x64\\php.exe"
    

    On my computer settings.json looks like this:

    {
        "terminal.integrated.shell.windows": "C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\git\\bin\\bash.exe",
        "terminal.integrated.env.windows": {
            "PATH": "C:\\Users\\[YOUR_USERNAME]\\AppData\\Local\\Yarn\\config\\global\\node_modules\\.bin;C:\\Users\\[YOUR_USERNAME]\\AppData\\Roaming\\Composer\\vendor\\bin;C:\\Users\\[YOUR_USERNAME]\\AppData\\Roaming\\npm;C:\\[PATH_TO_LARAGON]\\Laragon\\bin;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\apache\\httpd-2.4.35-win64-VC15\\bin;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\composer;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\git\\bin;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\git\\cmd;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\git\\mingw64\\bin;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\git\\usr\\bin;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\laragon\\utils;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\mysql\\mysql-5.7.24-winx64\\bin;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\nginx\\nginx-1.16.0;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\ngrok;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\nodejs\\node-v12;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\notepad++;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\php\\php-8.0.3-Win32-vs16-x64;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\putty;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\redis\\redis-x64-3.2.100;C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\telnet;C:\\[PATH_TO_LARAGON]\\Laragon\\usr\\bin;${env:PATH}"
        },
        "php.validate.executablePath": "C:\\[PATH_TO_LARAGON]\\Laragon\\bin\\php\\php-8.0.3-Win32-vs16-x64\\php.exe"
    }
    

    You can check what's in the PATH environment variable by opening the terminal and typing env. To check which path to binary is used for php, composer, etc., type which php, which composer, etc.

    Of course, [YOUR_USERNAME] should be your username, and [PATH_TO_LARAGON] should be the path to the folder containing Laragon.

    Don't forget to change the paths if you start using another versphp ion (of php, apache, ...). On other operating systems, the solution should be similar, but this answer is for Windows.