However, these days I'm mostly developing for servers my company or I administer, so I don't need to make the assumption that there is "no place outside the DocumentRoot." Instead, I designate the top level of the repo as a free-for-all, and specify one folder within as the DocumentRoot.
This means that all sorts of housekeeping can go on up in the repo root, like having composer files and its vendor tree. Like having the .git folder and files safely tucked away. Like having a build script that pre-compresses a bunch of JavaScript/CSS... or a Makefile. Or an extra document root with a static "Closed for maintenance" page. The possibilities are almost endless.
Some of our sites rely on RewriteRules, and that configuration also lands outside the DocumentRoot, to be included from the system Apache configuration. This lets us perform rewrites at the more-efficient server/URL level instead of filesystem/directory level, while allowing all the code to be updated in the repo. When we change rewriting rules, that goes right into the history with everything else.
To give a concrete example, a website could look like this on the server:
- public/
- index.php
- login.php
- pdf-builder.php
- pdf-loader.php
- css/
- js/
- img/
- tcpdf/
- (the TCPDF library code)
- built-pdf/
- 20141011/
- 1f0acb7623a40cfa.pdf
- cron/
- expire-built-pdfs.php
- conf/
- rewrite.conf
- composer.lock
- composer.json
- vendor/
- aws/
- aws-sdk-php/
- guzzle/
- ...
Again, this doesn't really work for letting other people publish on a shared host (rewrite.conf could conceivably do anything allowable in VirtualHost context, not just rewrite) but we own the whole host.
No comments:
Post a Comment