PHP Classes

File: src/config/config.inc.php

Recommend this page to a friend!
  Packages of Pierre-Henry Soria   PHP RESTful API Example   src/config/config.inc.php   Download  
File: src/config/config.inc.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP RESTful API Example
Example implementation of a REST API
Author: By
Last change:
Date: 3 years ago
Size: 685 bytes
 

 

Contents

Class file image Download
<?php
/**
 * @author     Pierre-Henry Soria <hi@ph7.me>
 * @website    https://ph7.me
 * @license    MIT License
 */

namespace PH7\ApiSimpleMenu;

use Dotenv\Dotenv;

enum Environment : string
{
    case DEVELOPMENT = 'development';
    case PRODUCTION = 'production';

    public function environmentName(): string
    {
         return match($this) {
            self::DEVELOPMENT => 'development',
            self::PRODUCTION => 'production'
        };
    }
}

$path = dirname(__DIR__, 2);
$dotenv = Dotenv::createImmutable($path);
$dotenv->load();

// optional: check if the necessary values are in the .env file
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS']);