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

Reindex on Composer Require #299

Closed
davidbarratt opened this issue Jul 12, 2017 · 3 comments
Closed

Reindex on Composer Require #299

davidbarratt opened this issue Jul 12, 2017 · 3 comments

Comments

@davidbarratt
Copy link

I use the Composer CLI to install packages, like

composer require guzzlehttp/oauth-subscriber

However the classes in the package do not become visable in Atom until I forcibly re-index the project.

Is there a way I can invoke the reindex? (i.e. add a script to my composer.json or something?)

@Gert-dev
Copy link
Owner

It should be sufficient to reindex the project (i.e. not forcibly reindex), as the former will scan for new, updated and removed files. That way you don't have to wait as long.

Regarding your question: I think it may be possible, but I don't think there's an easy way to currently do it. In theory the only thing the "Reindex" command does is send a reindex request to the PHP server with the paths of the project attached, after which the server will do the rest. Currently it would involve doing anything of the following:

  • Writing an external script (JavaScript?) that hooks into Atom somehow and executes a command, which could then execute the Reindex command from this package, which will handle the rest.
  • You can use your init.coffee to execute the Atom command manually, but the question then remains how to trigger this function inside Atom from outside Atom itself (perhaps there is some kind of package that can do it).
  • Write a script of app in any language that supports sockets that connects to the running PHP server using a socket client. The core server should support multiple socket clients. You'd have to fetch the port the server is running on from ps aux | grep Main.php or similar as the port is randomly determined on startup in Atom when the server is first spawned. After you've connected, you can then send a JSON-RPC request to reindex the appropriate folder in the same way the base package does.

This may or may not be too complex for what you're looking for :-).

The last option is to simply wait, as this (watching file modifications) is something that is on the roadmap. I can't give any guarantees as to when it might be implemented, though. I can say it likely won't be anytime soon on my part, as Atom's currently already working towards it, so I'd rather wait to save myself work on things I'll have to remove later :-).

@davidbarratt
Copy link
Author

Another way to do this would just be to watch the composer.lock file since it will be created/updated on initial composer install or any composer update

@Gert-dev
Copy link
Owner

Gert-dev commented Jul 28, 2017

I agree. There currently is some bandaid code that listens to "Git repository updates" (when they happen isn't really clear) from Atom and fires an index for the project when they happen.

File watching would be a much better solution and is tracked in [1] for the core. However, Atom now might implement this client-side, which would make this substantially easier for me (and according to the Language Server Protocol it's not the server's responsibility to actually watch paths, only to process events related to them).

File watching would also work for any file, i.e. there wouldn't be a need to watch composer.lock as any file created or modified anywhere could trigger the update.

(Closing this to keep the discussion centralized.)

[1] https://gitlab.com/php-integrator/core/issues/44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants