diff --git a/.gitignore b/.gitignore index 8c3ae97..b75f30f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ /src/config/*.php !/src/config/bootstrap.php -!/src/config/env.default.php +!/src/config/env.example.php /src/public/api/manifest.json /src/public/api/users.json diff --git a/src/config/bootstrap.php b/src/config/bootstrap.php index e3703a8..bc682ae 100644 --- a/src/config/bootstrap.php +++ b/src/config/bootstrap.php @@ -3,19 +3,29 @@ // PHP declare(strict_types=1); -// Environment -if (!empty($_SERVER['PHP_ENV']) && file_exists(sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV']))) +// Init environment +if (empty($_SERVER['PHP_ENV'])) { - require_once sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV']); + $_SERVER['PHP_ENV'] = 'default'; } -else require_once __DIR__ . '/env.default.php'; +// Generate configuration file if not exists +if (!file_exists(sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV']))) +{ + copy( + __DIR__ . '/env.example.php', + sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV']) + ); +} -// Autoload -require_once __DIR__ . '/../../vendor/autoload.php'; +// Load environment configuration +require_once sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV']); -// Local +// Local internal dependencies require_once __DIR__ . '/../library/database.php'; require_once __DIR__ . '/../library/sphinx.php'; require_once __DIR__ . '/../library/scrapeer.php'; -require_once __DIR__ . '/../library/time.php'; \ No newline at end of file +require_once __DIR__ . '/../library/time.php'; + +// Vendors autoload +require_once __DIR__ . '/../../vendor/autoload.php'; \ No newline at end of file diff --git a/src/config/env.default.php b/src/config/env.example.php similarity index 96% rename from src/config/env.default.php rename to src/config/env.example.php index e8cd33d..7a8548e 100644 --- a/src/config/env.default.php +++ b/src/config/env.example.php @@ -23,10 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * - * Default configuration file - * - * For different environments, use separated env.NAME.php files - * * Project home page * https://github.com/YGGverse/YGGtracker *