Last active
August 29, 2015 14:23
-
-
Save rossriley/a1647629c70a0336df4f to your computer and use it in GitHub Desktop.
Custom Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Boorj\Bolt; | |
use Bolt\Configuration\Standard; | |
use Symfony\Component\HttpFoundation\Request; | |
class Configuration extends Standard | |
{ | |
/** | |
* Constructor initialises on the app root path. | |
* | |
* @param string $path | |
* @param Request $request | |
*/ | |
public function __construct($path, Request $request = null) | |
{ | |
parent::__construct($path, $request); | |
$this->setPath('vendor', 'app/vendor'); | |
$this->setPath('cache', 'app/vars/cache'); | |
$this->setPath('logs', 'app/vars/logs'); | |
$this->setPath('database', 'app/database'); | |
$this->setPath('extensionspath', 'app/extensions'); | |
$this->setPath("themebase", 'src'); | |
$this->setPath('config', 'src/config'); | |
$this->setPath('extensionsconfig', 'src/config/extensions'); | |
$this->setPath("web", 'web'); | |
$this->setPath('files', 'web/up'); | |
} | |
} | |
// New index.php | |
use Boorj\Bolt\Configuration; | |
$configuration = new Configuration(dirname(__DIR__); | |
$configuration->getVerifier()->disableApacheChecks(); | |
$configuration->verify(); | |
$app = new Bolt\Application(array('resources'=>$configuration)); | |
$app->initialize(); | |
....... |
It can go anywhere in your autoloaded paths. So for example if I'm starting a new Bolt project I'll also define a root composer.json for that site and put a line like this in it.
"autoload": {
"psr-4": {
"MySite\\": "src",
"MySite\\Tests\\": "tests"
}
}
Then you can autoload any classes eg: MySite\Bolt\Configuration
will be loaded from src/Bolt/Configuration.php
That way you can swap out any individual services within Bolt for your own, if you want to change any of the core functionality. The line below now uses your custom Confguration class rather than the Bolt default.
use MySite\Bolt\Configuration;
$configuration = new Configuration(dirname(__DIR__);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry for stupid question, but where should i put this file? To
/extensions/local/boorj
or somewhere else? Usually i have to put there and createinit.php
file so bolt sees this extension and uses it.