This is an automated archive.

The original was posted on /r/php by /u/mapfilterreduce on 2023-09-06 23:59:25+00:00.


For our web app, we have the typical “meta” files (idk what to call them) like .editorconfig, .phpcs.xml.dist, .docker-compose.yml, package.json, phpunit.xml.dist, tests directory, etc, that manage our development and build tooling. Currently I have them in the project root, which seems to be pretty standard.

But when deploying our app, production does not need 90% of those files or folders that are in the root. So I currently employ a .deployignore file that is used to exclude those files from ending up on the production server when a deployment pipeline is run (boils down to rsync --exclude-from=.deployignore).

Our typical projects will have about 30 files listed in that exclude file.

Recently though I’ve been thinking of either:

A) moving all the files that need to be on production into a folder within the project root, and then the deployment simply pushes just the contents of that folder, no .deployignore required.

This presents a couple issues like requiring I modify Composer’s vendor folder to use something like app/vendor instead of the default. I know that is possible, but it’s also usually discouraged to veer away from that default (don’t want to go against established standards). It also feels a little awkward to have the src directory one level beneath root (so /app/src/Namespace/File.php, but then /tests/Namespace/FileTest.php for example).

This repo would look like:

├── app │   ├── bootstrap.php │   ├── config │   ├── public │   ├── src │   └── vendor ├── tests ├── .editorconfig ├── build.sh ├── composer.json ├── deploy.php ├── docker-compose.yml

B) leave everything in root, but on deploy copy the necessary files to a temporary “release” directory that will then be deployed. There would only be a handful of files to include, rather than the 30 or so we exclude (mkdir release && cp public src vendor bootstrap.php release && deploy release/).

Any feedback is appreciated!