protected function configureEnvironment() { $this->config = $this->app['config']->get("multi-tenant.{$this->tenant}"); // set base url Url::set($this->hostname); // set database $this->app->singleton('flarum.db', function () { $factory = new ConnectionFactory($this->app); $connection = $factory->make(array_merge($this->app->make('flarum.config')['database'], array_get($this->config, 'database', []))); $connection->setEventDispatcher($this->app->make('Illuminate\\Contracts\\Events\\Dispatcher')); $connection->setFetchMode(PDO::FETCH_CLASS); return $connection; }); }
use Flarum\Core; use Flarum\Core\Application; use Illuminate\Cache\FileStore; use Illuminate\Cache\Repository; use Illuminate\Config\Repository as ConfigRepository; use Illuminate\Filesystem\Filesystem; define('FLARUM_START', microtime(true)); require __DIR__ . '/vendor/autoload.php'; // franzliedke/studio currently doesn't autoload files (see issue below), so we // will need to load them manually if we're using studio. // https://github.com/franzliedke/studio/issues/29 if (file_exists(__DIR__ . '/core')) { require __DIR__ . '/core/src/helpers.php'; require __DIR__ . '/core/vendor/swiftmailer/swiftmailer/lib/swift_required.php'; } $app = new Application(realpath(__DIR__)); $app->instance('path.public', __DIR__ . '/..'); Illuminate\Container\Container::setInstance($app); if (file_exists($configFile = __DIR__ . '/../config.php')) { $app->instance('flarum.config', include $configFile); } date_default_timezone_set('UTC'); $app->instance('config', $config = new ConfigRepository(['view' => ['paths' => [realpath(base_path('resources/views'))], 'compiled' => realpath(storage_path() . '/framework/views')], 'mail' => ['driver' => 'mail'], 'cache' => ['default' => 'file', 'stores' => ['file' => ['driver' => 'file', 'path' => storage_path() . '/framework/cache']], 'prefix' => 'flarum'], 'filesystems' => ['default' => 'local', 'cloud' => 's3', 'disks' => ['flarum-avatars' => ['driver' => 'local', 'root' => public_path('assets/avatars')]]]])); $logger = new Monolog\Logger($app->environment()); $logPath = $app->storagePath() . '/logs/flarum.log'; $handler = new \Monolog\Handler\StreamHandler($logPath, Monolog\Logger::DEBUG); $handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, null, true, true)); $logger->pushHandler($handler); $app->instance('log', $logger); $app->alias('log', 'Psr\\Log\\LoggerInterface'); $app->singleton('cache', function ($app) {