Closed rrolla closed 2 years ago
Yes, this normally automatically happens during autocompletion. If you get autocompletion for Builder
in another file, selecting it should automatically add the import to the top of the file.
@Gert-dev Maybe this should be closed?
As I understand there is no extra menu for unimported stuff that can open and then click import?
@rrolla Hi.
Having such a menu, specially in a large project could be troublesome, both from performance and effectiveness perspectives. If you want to use
(import?) something, you can do one of the followings:
use
, type in some characters of the thing (i.e. the class or function) you want to import, from the autocomplete suggestions list, choose what matches best and hit enter. For example: type use Buil
, then choose Illuminate\Database\Eloquent\Builder
.use
statement is automatically placed at the top. For example: type new Buil
, then choose Builder
in which the namespace matches Illuminate\Database\Eloquent
.That's it.
If you are either partially or completely unable to use autocompletion, then see #501 and the workaround.
@rrolla Hi.
Having such a menu, specially in a large project could be troublesome, both from performance and effectiveness perspectives. If you want to
use
(import?) something, you can do one of the followings:
- Manually type
use
, type in some characters of the thing (i.e. the class or function) you want to import, from the autocomplete suggestions list, choose what matches best and hit enter. For example: typeuse Buil
, then chooseIlluminate\Database\Eloquent\Builder
.- Write the code and the implementation, and for example, when you want to create a new class, then choose it from the suggestions list. This way, the class
use
statement is automatically placed at the top. For example: typenew Buil
, then chooseBuilder
in which the namespace matchesIlluminate\Database\Eloquent
.That's it.
If you are either partially or completely unable to use autocompletion, then see #501 and the workaround.
Thanks for the tip @machitgarha
is it possible to import php namespaces on atom?
For example I type hint Builder class but to make it work I need to import it, and only thing to get namespace is to look on laravel api (https://laravel.com/api/5.8/Illuminate/Database/Eloquent/Builder.html) Than manually copy: