This page looks best with JavaScript enabled

Setting up development environment for Laravel

 ·   ·  ☕ 2 min read

Laravel is cool and all, but does not quite provide the “out of the box” dev experience as ASP.NET or, gasp, Typescript.

Let us change that by using a few good editor tools and packages.

PHP Intelephense extension

I use VSCode and there is no better auto completion than PHP Intelephense. It is fast, reasonably accurate and provides more than few options for playing around the code.

Laravel Extra Intellisense extension

Install Laravel Extra Intellisense extension for -

  • Route names and parameters
  • Suggestions in middlewares
  • Views

Laravel Snippets extension

Install Laravel Snippets extension for Laravel snippets.

Laravel Blade Snippets extension

Install Laravel Blade Snippets extension for Laravel Blade snippets.

Laravel IDE Helper package

Install [Laravel IDE Helper] https://github.com/barryvdh/laravel-ide-helper for better auto completion in Laravel.

1
composer require --dev barryvdh/laravel-ide-helper

Address Auto Complete Annoyances for Laravel and PHP in VSCode

When you open Laravel code, you will see autocomplete suggestions, but you will see a lot more than desired. The suggestions -

  • lacks context
  • has generic suggestions

There are a few things you can do -

  • Ctrl + Shift + p > Go to Preferences > Open Settings (UI). Search for editor.snippetSuggestions and set it to bottom
  • Next, search for php.suggest.basic and set it to false

Set Alias for php artisan

You will be typing php artisan at least a hundred times a day - better to save all the calories by setting an alias or a shortcut.

In Powershell, open your default profile -

1
notepad $Profile

Enter the below to set alias to pa-.

1
function pa { php artisan $args }

If you use wsl, you would be using bash or zsh. Just edit your .bashrc or .zshrc file to add an alias.

1
2
3
vim ~/.bashrc
# .. or
# vim ~/.zshrc

Add the below line -

1
alias pa='php artisan'

Now you can type pa instead of php artisan with how many ever arguments and it should work seamlessly.

Use Laravel debugbar.

Install the debugbar in your Laravel project.

1
composer require barryvdh/laravel-debugbar --dev

Ensure your .env file has APP_DEBUG=true and APP_ENV=local.

Start your Laravel server and you should see the debugbar at the bottom of the page.
See the documentation for more options.

Stay in touch!
Share on

Prashanth Krishnamurthy
WRITTEN BY
Prashanth Krishnamurthy
Technologist | Creator of Things