简体   繁体   English

带有 Laragon PATH 环境变量的 VSCode 中的 Laragon 终端

[英]Laragon terminal in VSCode with Laragon PATH environment variable

How to use the Laragon terminal in VSCode with Laragon PATH environment variable (on Windows)?如何在带有 Laragon PATH 环境变量的 VSCode 中使用 Laragon 终端(在 Windows 上)?

I want to use the Laragon terminal in Visual Studio Code.我想在 Visual Studio Code 中使用 Laragon 终端。
I want to use the local Laragon PHP, Composer, MySQL, Node.js, etc. in the terminal.我想在终端使用本地的Laragon PHP、Composer、MySQL、Node.js等。

  1. Open Laragon, right click > Tools > Path > Manage Path .打开 Laragon, right click > Tools > Path > Manage Path
  2. Copy everything between the --- Laragon --- and the next section (probably --- User --- ).复制--- Laragon ---和下一部分(可能是--- 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.我还将以C:\\Users\\[YOUR_USERNAME]\\AppData\\开头的三行放在开头,因此使用 Laragon 作曲家和 npm 而不是全局的。
  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:打开您的项目settings.json ,并添加以下值:
"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.第一行将 Laragon 终端设为默认值。 The second one makes the terminal use the Laragon paths/binaries.第二个使终端使用 Laragon 路径/二进制文件。
6. You can also add the Laragon php path as the language validation executable: 6. 您还可以添加 Laragon php 路径作为语言验证可执行文件:

"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:在我的电脑settings.json上。json 看起来像这样:

{
    "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 .您可以通过打开终端并键入env来检查 PATH 环境变量中的内容。 To check which path to binary is used for php, composer, etc., type which php , which composer , etc.要检查哪个二进制路径用于 php、composer 等,请键入which phpwhich composer等。

Of course, [YOUR_USERNAME] should be your username, and [PATH_TO_LARAGON] should be the path to the folder containing Laragon.当然, [YOUR_USERNAME]应该是您的用户名, [PATH_TO_LARAGON]应该是包含 Laragon 的文件夹的路径。

Don't forget to change the paths if you start using another versphp ion (of php, apache, ...).如果您开始使用另一个 versphp 离子(php,apache,...),请不要忘记更改路径。 On other operating systems, the solution should be similar, but this answer is for Windows.在其他操作系统上,解决方案应该类似,但此答案适用于 Windows。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM