Last active
August 29, 2015 14:23
-
-
Save rossriley/a1647629c70a0336df4f to your computer and use it in GitHub Desktop.
Custom Configuration
This file contains hidden or 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(); | |
....... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Then you can autoload any classes eg:
MySite\Bolt\Configuration
will be loaded fromsrc/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.