Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to import namespaces? #510

Closed
rrolla opened this issue Oct 4, 2020 · 5 comments
Closed

How to import namespaces? #510

rrolla opened this issue Oct 4, 2020 · 5 comments
Labels

Comments

@rrolla
Copy link

rrolla commented Oct 4, 2020

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:

use Illuminate\Database\Eloquent\Builder;
@Gert-dev
Copy link
Owner

Gert-dev commented Nov 6, 2020

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.

@machitgarha
Copy link
Collaborator

@Gert-dev Maybe this should be closed?

@rrolla
Copy link
Author

rrolla commented Aug 30, 2021

As I understand there is no extra menu for unimported stuff that can open and then click import?

@machitgarha
Copy link
Collaborator

@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:

  1. 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: type use Buil, then choose Illuminate\Database\Eloquent\Builder.
  2. 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: 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
Copy link
Author

rrolla commented Sep 2, 2021

@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:

  1. 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: type use Buil, then choose Illuminate\Database\Eloquent\Builder.
  2. 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: 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.

Thanks for the tip @machitgarha

@rrolla rrolla closed this as completed Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants