Laravel新手:如何在VS Code中启动项目并进行调试?
How to Start a Laravel Project in VS Code (For Beginners)
Hey there! Since you're new to Laravel and looking to launch your project in VS Code, let me walk you through the simple, straightforward steps to get up and running:
1. Open Your Laravel Project in VS Code
- Launch VS Code on your machine.
- Click File > Open Folder (or use the shortcut
Ctrl+K Ctrl+Ofor Windows/Linux,Cmd+K Cmd+Ofor Mac). - Navigate to the root folder of your existing Laravel project and select it. If you haven’t created a project yet, run
composer create-project laravel/laravel your-project-namein your terminal first to generate one.
2. Launch the Built-in Terminal
VS Code’s integrated terminal saves you from switching between apps:
- Open the terminal by clicking Terminal > New Terminal (or use the shortcut
Ctrl+`for Windows/Linux,Cmd+`for Mac). - The terminal will automatically load at the root directory of your Laravel project—perfect for running commands.
3. Start the Laravel Development Server
This is the core step to run your project locally:
- In the VS Code terminal, run this command:
php artisan serve - Once it’s up and running, you’ll see output like this:
Laravel development server started: http://127.0.0.1:8000
- Copy that URL, paste it into your browser, and you’ll see Laravel’s default welcome page!
4. Optional: Boost Your Workflow with Extensions
To make your Laravel journey smoother, install these handy VS Code extensions:
- Laravel Blade Snippets: Adds time-saving snippets for Blade templates.
- PHP Intelephense: Provides robust auto-completion and syntax checking for PHP code.
- Laravel Extra Intellisense: Enhances code suggestions for Laravel-specific elements like routes, views, and models.
Quick Troubleshooting Tips
- If you get a "command not found" error for
php artisan, double-check that your terminal is pointed to the root directory of your Laravel project. - If port 8000 is already in use, run
php artisan serve --port=8080to use a different port instead.
内容的提问来源于stack exchange,提问作者Fred
相关产品推荐
相关产品推荐

