Skip to content

Instantly share code, notes, and snippets.

@DaveRandom
Created August 2, 2016 10:07
Show Gist options
  • Save DaveRandom/f16d8529de3a5095e46a8422aaa6fa4d to your computer and use it in GitHub Desktop.
Save DaveRandom/f16d8529de3a5095e46a8422aaa6fa4d to your computer and use it in GitHub Desktop.
Default repository layout - PHP web application
vendor # ignore composer data
# ignore PHP Storm config
# you may want to ignore your IDE config and you may want to commit it, up to you
.idea
{
// ...
"autoload": {
"psr-4": { "MyAppNamespace\\": "src/" },
"files": ["src/functions.php"]
}
}
# this just ignores everything in this folder, while allowing you to commit the "empty" folder to git
*
|
+- .git
+- [public] # this is the web server document root, all requests for URIs that don't point to existing files are routed to index.php
| +- [static]
| | +- # static files; CSS, JS, images etc
| +- index.php
+- [config]
| +- .gitignore
+- [src]
| +- <PSR-4 namespaced classes>
| +- launcher.php
| +- bootstrap.php
| +- functions.php # there may be more than one of these, e.g. for different namespaces
+- .gitignore
+- .gitattributes
+- composer.json
+- composer.lock
+- readme.md
<?php declare(strict_types = 1);
require __DIR__ . '/../launcher.php';
<?php declare(strict_types = 1);
namespace MyAppNamespace;
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../config/config.php'; // load app config, may be more complex e.g. JSON/yaml files etc
// any other startup actions that are required for every application entry point, e.g. if you have any command line scripts
<?php declare(strict_types = 1);
namespace MyAppNamespace;
require __DIR__ . '/bootstrap.php';
// this is the actual entry point for the web application, app logic goes here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment