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

Add Support for an Abstract Filesystem #269

Closed
timglabisch opened this issue Apr 18, 2014 · 13 comments
Closed

Add Support for an Abstract Filesystem #269

timglabisch opened this issue Apr 18, 2014 · 13 comments

Comments

@timglabisch
Copy link

in my case intellij isn't able to get the content of my cache directory (i use vagrant + rsync).

i played a bit with implementing an abstract filesystem to implement a way to fetch the container.
it's just a prototype i learned a bit about writing intellij applications.

https://github.com/timglabisch/idea-php-symfony2-plugin/commits/abstract_filehandling

I tryed to implement my own file handlers.
https://github.com/timglabisch/idea-php-symfony2-plugin/blob/abstract_filehandling/src/fr/adrienbrault/idea/io/FileFactory.java

but may it would be better to just use the VirtualFileSystem from intellij.

i don't know a lot about intellij and normal times don't program java so for now i wasn't able to find a way to parse the PSI Elements from my IFile interface to support routes.
https://github.com/timglabisch/idea-php-symfony2-plugin/blob/abstract_filehandling/src/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java#L144

what do you think about about supporting an abstract filesystem to work with "remote caches"?

@Haehnchen
Copy link
Owner

thx, vagrant and external file are still an issue #14, #262, #244.
i dont know how to resolve is issue in a good way. your idea of using a rest + abstraction layer is also something i was thinking of. i think the "abstract filesystem" break too much intellij stuff, but i will validate this.

since phpstorm7 we have vagrant in core. its just a plugin "vagrant.jar" with the help of "jd-gui" we can get the source code. if they provide some download api inside, we can also go this way.

@timglabisch
Copy link
Author

I've played around with creating a temp file to convert my IFile to an instance of an Virtualfile / PsiFile.
https://github.com/timglabisch/idea-php-symfony2-plugin/blob/abstract_filehandling/src/fr/adrienbrault/idea/io/File/Abstract.java#L19
this is a bit hacky but works for me at the moment.

it allows me use the routes from my rest service.

from my point of view this ticket must not be related to vagrant.
just think about lxc containers, jails or using the local shared memory to store the cache.

would be more interesting to allow the paths in the symfony2 plugin configuration to be loaded by different protocol drivers?

like:
path to urlGenerator.php ->
http:// ... for rest
ftp:// ...
ssh:// ...
smb:// ...
vagrant:// (ssh'ing to the box based on the ip in the vagrantfile)
exec:// .... to invoke an executeable and get it's input stream

rest isn't a good solution, especially in terms of security and performance. would be pain if intellij stops because you're in a xdebug breakpoint and the it can't load the files.
i think the best solution could be to just implement an abstract way to get the content.

@Haehnchen
Copy link
Owner

ok, good point. all ideas to load external files are welcome.
but however we need to decuple the regeneration. currently we can just reload a file when necessary in any extension point, but moving (remote-)protocols will block the ide then. so some overall watcher-thread need to implemented. this thread can then fill the cache.

btw. try a look on PhpPsiElementFactory.createPsiFileFromText() :)

@timglabisch
Copy link
Author

thanks, searched for something like PhpPsiElementFactory.createPsiFileFromText() for a while [...].
i updated the code.

i totally agree with you, blocking remote protocols would be pain.
a background thread that checks the remote system could work well.

invalidating the remote file cache could be triggered by usage or using a button in the UI.

the intellij api makes it impossible to implement pure async io. for example look at the FileBasedIndexExtension, methods like isValidForIndex force you to implement blocking requests.

what do you think about mixing async io with blocking io for the initial file request.
some timeouts + error reporting could prevent bad user experience or issues with very slow backends.

@Haehnchen
Copy link
Owner

no, FileBasedIndexExtension is a background task. you see its working when "Indexing..." is shown in bottom toolbar. moreover its run on every file change (without u know it), so its complete in "non-blocking" mode and deactivate all intellij extensions on a long process eg on reindexing.

we need to have a valid cache everytime when a request from an extension is coming. there so much traffic around there that we cant wait for an operation. therefore u dont see "synchronized" methods on list/collection generations. its faster to create a new instance.

implemention of such a background task would be easy. just throw it into a scheduler; run it every x minutes and we are ready :)

// com.intellij.openapi.progress.Task
        new Task.Backgroundable(project, "Background Bottom Message", true) {
            @Override
            public void run(@NotNull ProgressIndicator indicator) {
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException ignored) {
                }
            }

        }.queue();

@Haehnchen
Copy link
Owner

also related to #138 would be a good testcase

@gfreeau
Copy link

gfreeau commented Jun 5, 2014

Could this be achieved with the "add additional symfony xml container files" option? The appDevDebugProjectContainer.xml can be retrieved from the vagrant vm with something like rsync and the path to this file is added as an additional container file.

@Haehnchen
Copy link
Owner

u can add new container files in plugin settings. just rsync them. but target is to remove this step, however we can to this in a good way :)

@Koc
Copy link
Contributor

Koc commented Jul 25, 2014

I've got same problem: we are using virtualbox for dev env and I should sync cache folder by hands.

@epicwhale
Copy link

Same problem. I use vagrant + NFS. And I've moved the symfony2's cache/logs directory under /tmp/symfony/cache/dev/... (to make it faster inside vagrant).

I am manually also doing a cache:clear on the host system to generate the appDevDebugProjectContainer.php + appDevDebugProjectContainer.xml files and then symlinking this to the /tmp/symfony/cache/dev... files on my system. This is the only way I've managed to get it to work with this plugin and got rid of the "Weak Service" notices.

Why doesn't the adding additional XML Container files work? Does the plugin require the XML file or the appDevDebugProjectContainer.php to resolve all services? I'm confused.

@Kifah
Copy link

Kifah commented Sep 30, 2014

Same problem here....We use vagrant and the route to cache folder is /var/cache/symfony. Would be cool to setup the plugin, while having access to the vagrant file system to configure the paths.

@Haehnchen
Copy link
Owner

update: i have started a branch for resolve this. basically phpstorm provides a http-server which listens for data of external "boxes".feature/server-storage. there also simple php lib: https://github.com/Haehnchen/ide-tools. iam finalize it in the upcoming weeks...

@timglabisch
Copy link
Author

i changed my mind on this topic. i think a good solution is the "deplyoment" feature of phpstorm. it's quite easy to sync a folder using this feature.

Haehnchen added a commit that referenced this issue Mar 2, 2016
add settings to enabled background scheduler
add action to download Symfony dev files directly inside server browser
add routing service remote storage to its collector
add plugin webDeployment for testing environment
support temporary psi files for routing of remote files
add support for load container file on remote
add remote ui also for container selection
refactoring of webDeployment features
add basic timer for loading remote files of routing on webDeployment plugin
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

6 participants