0

I can't find a more appropriate. I'm using PhpStorm to create web content (php, html, css, js..) and I'm facing the problem of long files (not even so long few hundred lines enough to be lost) where it gets hard to find things and remove unnecessary content.

I was wondering if there is a functionality, plugin or external file manager where it creates different files from one file on disk.

For example: when we have a .css file, for sure it's content is dealing with different features/parts of the html but they are all on the same html page. So it's a bad idea to create different .css file for each part, but it would be nice to have different virtual files for each part/feature where we can code and debug separately our code; but they are saved to same file.

Lets say:

  1. common_header.css: deals with headers
  2. common_menu.css: deals with menu (some menu we have on our page)
  3. common_footer.css: deals with what ever to the end of page
  4. ... and so on

So now while coding we see different files (best as a subtree of the original file) some thing like that on file manager:

  • ....other file // the dot here should be + since subtree hidden

  • common.css // the dot here should be - since subtree is shown

    • common_header.css
    • common_menu.css
    • common_footer.css
    • ...
  • ....other file

But when on disk they are all on the same file common.css that is loaded to our browser as one too.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
fekiri malek
  • 354
  • 1
  • 3
  • 14
  • PhpStorm does not have such functionality .. and I doubt that will ever have. In reality, what everyone is doing, is to actually have separate files and then merge/glue them together before deployment/testing (a simple Grunt/Gulp task or whatever). Such routine can also be called automatically on file save via File Watcher functionality or via own Grunt's/Gulp's `watch`. You can also use CSS pre-processors (like LESS/Sass/etc) to do such inclusion (they have options to treat included file as CSS instead of source less/sass that still needs processing) – LazyOne Sep 08 '16 at 09:07

1 Answers1

0

If your target is to reduce the number of files being loaded from your server, after the application has been deployed, you might merge and compress your files as shown here.

In case you don't want to waste computing time to compress the files on each call, you could adjust your build process to generate them once during build (something like minify).

Ahatius
  • 4,777
  • 11
  • 49
  • 79
  • thank you for your reply, i consider that for the deployment. but my question is about when just coding. to facilitate it through having different snippet with different functionalities on different view but saved on the same file (as it would be when deploying). sure we can consider to create different files now and eventually concatenate them. but its more unnecessary work i see. and its better to have fixed the file structure from the start. – fekiri malek Sep 08 '16 at 08:16
  • I don't know PHPStorm so I'm not sure if there is anyway to achieve what you want. Usually this is done when you're building or deploying the application. But you might create a script that does this when saving your file, see [here](https://confluence.jetbrains.com/display/PhpStorm/File+Watchers+in+PhpStorm). – Ahatius Sep 08 '16 at 08:31