5

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.

Quirinus
  • 442
  • 1
  • 5
  • 9

2 Answers2

6
  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.

Quirinus
  • 442
  • 1
  • 5
  • 9
  • This works, thank you. But it's a bit of a drag to have to remember to open vs code's settings every time to change PHP paths over if you are frequently switching between PHP versions. It's a shame Laragon doesn't offer a direct automatic integration, given that it's so easy to switch versions in the Laragon menus. – Orchis Apr 14 '22 at 07:20
0

Just type code . in your project path in your laragon terminal

Chandra
  • 1
  • 1
  • Could you provide an example of your method? I know it sounds silly, but a lot of noobs would look at that and go: "huh?" Also, the accepted answer seems to be more "permanent," what might be the advantages of using your method (aside from not as much typing, lol :) )? – wileyCoyote Jun 18 '23 at 19:23
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 18 '23 at 19:24