You can create another class in your config file and it will serve as a wrapper for all your config values and operations. This is the best approach also if you are giving value to OOP in your project development.
config.php
<?php
/**
* PhpDoc...
*/
class YourConfig
{
/**
* Your constant value
*/
const DB_HOST = 'localhost';
/**
* @var string Some description
*/
private $layout = 'fluid';
/**
* Your method description
* @return string layout property value
*/
public function getLayout()
{
return $this->layout;
}
}
myclass.php
<?php
/**
* PhpDoc
*/
class MyClass
{
private $config;
public function __construct()
{
require_once( __DIR__ . '/config.php' );
$this->config = new Config();
}
protected function a()
{
// get a config
echo $this->config->getLayout();
}
}
You can use and extend this approach for what/however you want.
include