How to auto import laravel class in vs code

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Effortlessly Auto Import Laravel Classes in VS Code Using Extensions Introduction: In today's fast-paced world of software development, efficiency is the key to success. When working on a Laravel project using Visual Studio Code (VS Code) as your text editor, you may want to automatically import Laravel classes that you use during coding. This can be achieved with the help of VS Code extensions designed specifically for this purpose. In the following blog post, we'll explore how to find and install the best extension for auto-importing Laravel class files, as well as provide examples using it in your code. 1. Finding the Best Extension: Start by navigating to the VS Code Extensions Marketplace (https://marketplace.visualstudio.com/search?target=editor&term=laravel) and searching for Laravel-related extensions. Two popular options include "Laravel IDE Helper" and "Laravel Snippets." 2. Installing the Extension: Choose one of the above extensions as per your preference and install it in VS Code. Launch VS Code, go to the bottom left corner, and click on the extension icon next to the search bar. Type "Laravel" in the search bar and select the installed extension from the list. Click "Install" if it's not already installed. 3. Configuration: Each of these extensions has different configuration options. For the "Laravel IDE Helper," you can access its settings by clicking on the extension icon at the bottom left corner, then selecting "Preferences: Open User Settings (JSON)" from the pop-up menu. Paste the following code in your JSON file and save it: ```json "laravel-ide-helper.paths": [ "./app", // for application classes "./database/seeds", // paths to laravel vendor class "./database/factories", // for factory classes "./resources/views", // paths to views "./config", "./tests", "./routes" ] ``` For the "Laravel Snippets," there is no configuration required since it already comes with a predefined set of Laravel snippets. 4. Using the Extension: Open your VS Code project and start coding using Laravel classes such as Schema, DB, Eloquent models, etc. As soon as you refer to these classes in your code, the extension will automatically detect it and ask if you want to import that class or not. Choose "Yes" for any class required, and it will be added to your code with the necessary namespace line. 5. Additional Tips: You can configure the Laravel IDE Helper extension further by adding additional paths where it should search for classes. If you are working on a large project with multiple packages or vendor directories, add those as well to ensure all class imports are detected and added correctly. Conclusion: Utilizing extensions like "Laravel IDE Helper" or "Laravel Snippets" in VS Code can significantly improve your development efficiency by auto-importing Laravel classes when needed. This blog post aimed to provide a comprehensive guide on how to find, install, and use these extensions effectively. Remember, always check the marketplace for newer versions of these extensions and ensure they are compatible with your current VS Code version. Happy coding!