Laravel Phpstorm



After a long time, I wanted to show you another quick tip. At the moment I work a lot with InertiaJS, built by Jonathan Reinink. It allows you to create fully client-side rendered, single-page apps. It makes a lot of fun, but there was one thing that has always been annoying me. At least if you're using Laravel Mix.

If you take a look at the demo project PingCRM, there is a file called webpack.mix.js. You will find something like this:

This allows you to import components directly from the resources/js directory like so:

Laravel new example-app -github='-public' -organization='laravel' Initial Configuration. All of the configuration files for the Laravel framework are stored in the config directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you.

  1. Welcome to Mastering PhpStorm, a video course for the state-of-the-art PHP developer who wants to work efficient and successful in a beautiful IDE. This is the best way to learn and master PhpStorm.
  2. This is a small guide for people to help get them started with Laravel 5 on Windows using PHPStorm 2016 and WampServer 3. I am creating this because i.
Phpstorm

Phpstorm 2017

Environmental Science. System version: OSX 10.11.4. PHP Version: 7.0.5. Xdebug version: 2.4.0. Laravel version: 5.1.31. PHPStorm version: 10.0.4. Xdebug configuration. These will help by providing more information to IntelliSense for it to understand more of the Laravel's magic. Let's run these commands: $ php artisan ide-helper:generate $ php artisan ide-helper:meta $ php artisan ide-helper:models -nowrite If all went well, you will now have three new files in your project's root: idehelper.php.phpstorm.

What sucks now is, that you can not use PhpStorm autocompletion when you hover over the path, press cmd and click to jump to that file as you always do. This is because PhpStorm doesn't know how to resolve that.

The solution

But there is a solution of course. And it's quite easy.

Create a separate webpack file and extract that webpack configuration to that file. You end up something like this:

Laravel Phpstorm Ide Helper

webpack.config.js

The only thing you have to do now is to tell Laravel Mix to use that webpack configuration instead of the inline-configuration. You should end up with this in your webpack.mix.js:

The last step is to tell PhpStorm there is a webpack configuration that can be used. Because PhpStorm only accepts webpack configuration in this case, the above steps have been necessary.

Laravel Phpstorm

Go to the settings and define your new created webpack.config.js file there and you're done. It takes a little bit of time until PhpStorm recognizes it.

Php Storms

If everything worked paths like '@/Shared/Logo' should now be resolved by PhpStorms autocompletion and let you jump directly into that file.