在 VS 代码中使用 PHP 和 MySql

我想在 VS Code 中运行 PHP 和 MYSql,就像使用“xammp”运行一样。我遇到了一些要使用的扩展,例如 IIS-Express 和 vscode-database,但不知道如何配置并将它们链接在一起。哪些 PHP 适合,即线程安全或非线程安全。

PS:我完全是学习 PHP 和 VS Code 的新手,我想在我学习的每一种语言中都使用 VS Code :)

stack overflow Using PHP and MySql in VS Code
原文答案

答案:

作者头像

IIS Express is an extension that will basically run your project folder as a website. It's an extremely handy tool that I couldn't live without. Usage is simple, and noted below. I should also point out that IIS Express is only available for Windows and will not work on Linux or OSX.

  1. File > Open Folder
  2. Select the folder with your PHP and HTML within
  3. Install the IIS Extension from the extension menu. (Or with the command palette using "ext install iis-express")
  4. Open the command palette (CTRL + SHIFT + P)
  5. Type "IIS Express: Run Website"
  6. This starts the web server and will open a browser and connect to your website for testing.
  7. To stop the server, simply type the command a second time.

More information can be found here.


After looking around, it seems vscode-database does not host an actual database, but rather, gives you a way to test your queries in the editor. The information page for vscode-database doesn't make that very clear, though. So for MySQL functionality, you may want to look at running MySQL in a "portable mode". Instructions for this can be found here.

After getting that setup, you would just connect to it in php like any other MySQL database.