12

As you may know or not, Laravel 5.4 introduced automatic facades. I'm using PhpStorm and don't know if getting a working autocomplete is possible. Standard facades work because I'm using laravel-ide-helper, but (I guess) automatic facades don't work. Is there any solution?

Karl Hill
  • 12,937
  • 5
  • 58
  • 95

4 Answers4

1

As @jdenoc mentioned the package laravel-ide-helper, you can also try adding the gist _ide_helper.php file in the project's root folder, as Jeffrey Way briefly explained in his tutorial

moghwan
  • 1,829
  • 2
  • 17
  • 29
0

You should try using this composer package: barryvdh/laravel-ide-helper.
It is a Laravel 5 IDE Helper Generator

jdenoc
  • 75
  • 1
  • 3
  • 5
0

The only solution I know of is to create your own helper file. In PhpStorm, create a _ide_facades.php file in the root of your project. Then you can add the structure of your methods. As a contrived example, say we have NameService we import as Facades\App\Services\NameServiceand implement as:

<?php

namespace App\Services;

public class NameService
{
    public function upper(string $name): string
    {
        return str($name)->upper();
    }

    public function lower(string $name): string
    {
        return str($name)->lower();
    }
}

Then in our _ide_facades.php:

<?php
// @formatter:off

namespace Facades\App\Services\NameService {
    class NameService
    {
        public static function upper(string $name): string {}
        
        public static function lower(string $name): string {}
    }
}

Rinse and repeat for all your real-time facades adding each in their own namespace block. Hopefully someone will come up with a plugin or helper to do this automatically to spare us the effort of creating/maintaining manually.

Shawn Lindstrom
  • 622
  • 9
  • 16
0

you can use phpDocs in your codes for detection by phpstorm eg: // * @method static static make(string $classname)

kashef_php
  • 60
  • 4