PHP Classes

File: src/config/database.inc.php

Recommend this page to a friend!
  Classes of Pierre-Henry Soria   PHP RESTful API Example   src/config/database.inc.php   Download  
File: src/config/database.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: 7 months ago
Size: 543 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
RedBeanPHP\R;

// setup RedBean
$dsn = sprintf('mysql:host=%s;dbname=%s', $_ENV['DB_HOST'], $_ENV['DB_NAME']);
R::setup($dsn, $_ENV['DB_USER'], $_ENV['DB_PASS']);

// Freeze RedBean on production
$currentEnvironment = Environment::tryFrom($_ENV['ENVIRONMENT']);
if (
$currentEnvironment?->environmentName() !== Environment::DEVELOPMENT->value) {
    echo
'RedBean Frozen';
   
R::freeze();
}