Mark PHPStorm directory as Generated Sources root
Is there a way to mark a directory as a Generated Sources/Staging area root?
As is often the case in PHP development I have many files that are .js .html .css etc. that I need to run different types of processors on (autoprefixer, minifiers, etc.) The results of these sources need to go somewhere, so I have a `dist` directory in my project that gets populated with those. Then I do a local deployment from my src directory to the dist directory for the rest of the php and other files. Then finally I deploy the dist directory to whatever server I need to deploy to at the time.
It would be nice to have the ability to mark the dist directory as a Generated Sources root (like you can in Intellij Idea) so that it is excluded from indexing, but still available for deployment.
Please sign in to leave a comment.
Hello,
Well, you can exclude the directory from indexing by marking it as Excluded in File | Settings | Directories or via right click > Mark Directory As.
But excluding directories from deployment is a completely different thing and is managed in File | Settings | Build, Execution, Deployment | Deployment > server > Excluded Paths.
Does it work different for you?
Hi Vladimir,
It does seem to work differently. When I exclude the directory by marking it excluded (right click > Mark Directory As > Excluded), it no longer allows me to deploy from that directory. I can still deploy into that directory (src -> dist), but deploying from dist->local file server/remote file server doesn't work. I've been deploying via right click on dist > Sync With Deployed To > "MyDeploymentArea". I've tried with both local deployments (on the same machine) and remote via FTP.
In fact if I exclude the directory and then navigate to Tools > Deployment > Configuration and look at the Mappings tab of a specific deployment, PHPStorm gives me a warning at the bottom "Local path `C:\MyLocal\path\to\dist` is out of project."
I just tried doing an "Upload" instead of a sync, and that does work. But I would really like to get this to work with Sync because upload just overwrites all files in the destination, so it's not as clear what actually changed.
It just occurred to me that the Sync probably needs to utilize the index to be able to determine which files have changed... So this is probably not possible.
I have this exact same problem. If I exclude the dist folder I cannot sync from it to the deployment but if I don't exclude it, files from it show up in searches and Ctrl+Click usage lists.
I would be great to have a way to exclude it completely from all searches and indexing (unless explicitly chosen) but still be able to sync it to the deployment server. Any way of achieving this?
Hi Ben, Scott,
Looks like both of you enabled "Hide excluded files" option in Diff window that comes before Synchronization.
Please check if that is true.
Hi Vladimir
Yes, it is checked because I have some files/folders that are excluded from sync (eg files that exist or change on the server but I don't want to download to the dist folder each time, such as user uploads etc) and unchecking this causes all those other files/folders to sync as well which is not acceptable.
I just want a way to mark my dist folder in such a way that it is excluded from searches and indexing by default but NOT excluded from syncing to the deployment location. Marking it as 'Generated Sources' or similar would be ideal so the IDE can ignore it apart from syncing it to deployment.
Scott, unfortunately, it's a bug. Please vote: https://youtrack.jetbrains.com/issue/WI-27162
Hi Eugene
Looking through that issue and the ones related to it (especially WI-10309), it seems that different people have different interpretations of what an 'excluded folder' should do. I can mark a folder as 'Excluded' and if I go into settings where I can see more by hovering over the setting, it says 'Exclude from Module'. It is not clear what this means. Should it exclude it from indexing and searching but allow syncing to distribution, or should it block all? I assume it is SUPPOSED to be the former but the bug (from over 2 years ago!) stops it working correctly?
Please leave your feedback at corresponding bug thread - this way you will be heard by developers.
Vladimir's suggestion solves my issue; I did indeed have excluded files hidden. In my case I can have excluded files unchecked, but I agree with Scott in that "Excluded Files" really seems to imply that they don't belong in the project (like his example of user uploads or perhaps even local developer specific configurations that shouldn't be distributed). Being able to mark a directory as "Generated Sources" is something that I think most developers would benefit from.
Sounds like a great idea for a feature request. :-)
Feel free to submit it to our tracking system here: <http://youtrack.jetbrains.com/issues/WI#newissue=yes>.
Same or similar issue here. In my project, there is a lot of raw material that I don't want to have deployed to some server. So I have a `dist` folder that holds copies of or links to files and directories of my project. The dist folder is excluded from VCS because it is merely a container for distribution/deployment. But I don`t want to exclude it from deployment for sure. Annoyingly, I get (weak) error messages all over my project because of multiply defined classes, duplicated code and the like. Ignoring these opens up the chance to miss a _real_ warning. In another product (IntelliJ as I remember right) there is the choice of marking a directory as Generated root. In PhpStorm, there is no such thing, which is a pity. It would be greatly appreciated to have that possibility.
There actually are generated source roots in PhpStorm: https://recordit.co/zmA5EQysD1
What I don't understand is why everyone in this thread thinks that generated roots have something to do with deployment, even in IDEA, marking a folder as a generated source root has no effect on deployment, at least as far as I know.
@Eugene Morozov Thank you for pointing out how to mark a directory as generated source.
Apparently, I got on the wrong track asking for those "generated roots". Marking my dist folder as generated source does not solve the problem (neither does it in your solution, watch the nasty grey squiggles beneath the name of your class, FooBar).
As soon as a class or other global entity appears twice within a project, PhpStorm claims there is a duplicate definition. I am searching for a way to tell PhPStorm not to apply that sort of syntactical analysis to my dist folder. The same holds for the searching of some "duplicated" item (classes, constants, variables and the like). Marking the dist folder as Excluded would do this job perfectly. But then again, I could not deploy this dist folder.
Therefore: How can I have a distribution folder that acts merely as a container for deployment, holding copies of or links to files that are to be deployed, without PhpStorm complaining about duplicates?
I still have this exact same issue as H.-W. Wyes
I thought this was a pretty common workflow? I have all the main code in a working folder (app in my case) then use a build system (currently Gulp for me) to pull together all the required files, concatenate and compress to the SASS and JS, optimize images, etc, then put them in a folder (I also use dist) for uploading or distribution.
This folder output folder should be excluded from everything - duplicate checks, find & replace, code hints, source links, etc - apart from deployment (syncing or uploading) to a server. I still need to be able to exclude individual files/folders (either based to the local or the server path) as there may be items generated/uploaded server side, or different files for separate installations.
However, as far as I am aware, this is not currently possible. Originally, I was told it was a bug and I have also seen other posts or bug reports referring to that diagnosis, but as time has gone on it seems to have been downgraded to "that's not how it is supposed to work".
I am not holding my breath for a definitive answer. I absolutely LOVE PHPStorm but I find if none of the Devs use a similar workflow to you, then things like this just get swept under the carpet unless enough people complain - though I fully understand that you can't make the product work for absolutely everyone in exactly the way they want.