When developing PHP and Laravel applications, having the right tools in your code editor can significantly boost productivity. Visual Studio Code (VS Code) is an incredibly popular choice among developers due to its flexibility and extensive library of extensions. In this post, we’ll go over the best VS Code extensions specifically for PHP and Laravel development, covering everything from IntelliSense and code formatting to database management and Git support.
Why Use VS Code for PHP and Laravel?
VS Code provides a fast, lightweight setup with plenty of customization options. For PHP and Laravel developers, it supports many features that make coding easier, including:
- IntelliSense for smart autocompletions
- Easy-to-integrate extensions for Laravel and PHP
- Robust Git and version control tools
- Live preview, testing, and database tools
Let’s dive into the essential extensions for PHP and Laravel that can help you optimize your workflow and code quality.
1. PHP and Laravel Development
PHP Intelephense
-
Extension:
bmewburn.vscode-intelephense-client
- Description: A must-have for PHP developers, Intelephense provides advanced IntelliSense, code navigation, syntax error highlighting, and refactoring tools.
Laravel Extra IntelliSense
-
Extension:
amiralizadeh9480.laravel-extra-intellisense
- Description: This extension adds Laravel-specific IntelliSense, making it easy to work with Laravel-specific methods and helper functions right in your editor.
Laravel Blade
-
Extension:
onecentlin.laravel-blade
- Description: Adds syntax highlighting and snippets for Blade templates, Laravel’s templating engine. It also includes syntax highlighting for Blade directives.
Laravel Artisan
-
Extension:
ryannaddy.laravel-artisan
- Description: Quickly access Artisan commands directly from within VS Code. You can run commands, check routes, and perform other Artisan tasks without leaving your editor.
2. Code Formatting and Snippets
PHP CS Fixer
-
Extension:
junstyle.php-cs-fixer
- Description: Ensures your PHP code follows consistent styling by automatically formatting code to match PHP-CS-Fixer rules. This is essential for large projects with multiple developers.
Prettier - Code Formatter
-
Extension:
esbenp.prettier-vscode
- Description: Prettier is a powerful code formatter for JavaScript, CSS, and HTML. It helps ensure consistent styling in non-PHP parts of your Laravel projects.
Blade Formatter
-
Extension:
shufo.vscode-blade-formatter
- Description: Specifically designed for Blade templates, this extension automatically formats Blade files for a consistent look and structure.
Tailwind CSS IntelliSense
-
Extension:
bradlc.vscode-tailwindcss
- Description: Essential if you're using Tailwind CSS with Laravel. It provides IntelliSense for Tailwind classes and validates them in real-time, making it easy to use utility-first CSS classes.
3. Database and SQL Management
SQL Formatter
-
Extension:
adpyke.vscode-sql-formatter
- Description: Automatically formats SQL queries for readability. It’s invaluable when working with complex queries or stored procedures in your Laravel application.
SQL Beautify
-
Extension:
clarkyu.vscode-sql-beautify
- Description: Another helpful tool for formatting SQL, making it easy to write and read SQL queries.
Faker
-
Extension:
deerawan.vscode-faker
- Description: This extension generates fake data for testing purposes. It can be used to quickly add mock data to your Laravel applications, making it useful for prototyping and testing.
4. Environment and Utility Tools
DotENV
-
Extension:
mikestead.dotenv
-
Description: Adds syntax highlighting and basic linting to
.env
files, which is very useful for Laravel developers working with environment configurations.
Better Comments
-
Extension:
aaron-bond.better-comments
- Description: Improves the readability of comments by color-coding them. This helps when you need to differentiate between different types of comments, such as TODOs, notes, and warnings.
Auto Close Tag & Auto Rename Tag
-
Extensions:
formulahendry.auto-close-tag
andformulahendry.auto-rename-tag
- Description: These extensions are fantastic for HTML and Blade templates, automatically closing tags as you type and renaming matching tags to keep your code clean.
5. Git and Version Control
GitLens
-
Extension:
eamodio.gitlens
- Description: GitLens supercharges the built-in Git capabilities in VS Code, providing features like blame annotations, detailed commit histories, and code authorship tracking.
Git Graph
-
Extension:
mhutchie.git-graph
- Description: View your Git repository history as a graph, making it easy to visualize branches, merges, and commits. Perfect for projects with multiple collaborators.
6. Docker and Containers
Docker
-
Extension:
ms-azuretools.vscode-docker
- Description: This extension is essential if you’re deploying your Laravel applications in Docker containers. It allows you to manage images, containers, and Docker Compose files directly in VS Code.
7. Live Preview and Testing
Live Server
-
Extension:
ritwickdey.liveserver
- Description: Quickly launch a development server with a live reload feature. This is particularly useful for front-end work or when you want to see changes to Blade templates in real-time.
Pest and PHPUnit Snippets
-
Extensions:
dansysanalyst.pest-snippets
andshashraf.vscode-pestphp
- Description: Laravel developers can use Pest or PHPUnit for testing. These extensions provide useful snippets for both testing frameworks to speed up test writing.
Example extensions.json
for Laravel Projects
To share these recommendations with your team or keep a record of them, create an extensions.json
file in your project’s .vscode
folder. This will prompt VS Code to suggest these extensions whenever the project is opened.
Here’s a sample extensions.json
configuration:
{
"recommendations": [
"bmewburn.vscode-intelephense-client",
"amiralizadeh9480.laravel-extra-intellisense",
"junstyle.php-cs-fixer",
"codingyu.laravel-goto-view",
"onecentlin.laravel-blade",
"ryannaddy.laravel-artisan",
"shufo.vscode-blade-formatter",
"mikestead.dotenv",
"esbenp.prettier-vscode",
"bradlc.vscode-tailwindcss",
"eamodio.gitlens",
"mhutchie.git-graph",
"ms-azuretools.vscode-docker",
"adpyke.vscode-sql-formatter",
"clarkyu.vscode-sql-beautify",
"deerawan.vscode-faker",
"ritwickdey.liveserver",
"dansysanalyst.pest-snippets",
"shashraf.vscode-pestphp"
]
}
Conclusion
These VS Code extensions are invaluable tools for PHP and Laravel development, streamlining workflows and providing essential functionality. Whether you’re handling backend code, front-end styling, or database queries, these extensions can help keep your code clean, organized, and efficient.
Try adding these to your setup, and enjoy a more productive development experience with Laravel in VS Code!
Photo by Luca Bravo on Unsplash
Top comments (0)