Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
},
"autoload": {
"psr-4": {
"Sprout\\": "src/sprout"
"Sprout\\": "src/sprout",
"Sprout\\Core\\": "src/core"
},
"files": [
"src/sprout/preboot.php"
Expand Down Expand Up @@ -46,7 +47,7 @@
"ezyang/htmlpurifier": "^4.17",
"giggsey/libphonenumber-for-php": "^8.13",
"guzzlehttp/guzzle": "^7.9",
"karmabunny/kb": "^4.61",
"karmabunny/kb": "^4.61.44",
"karmabunny/pdb": "^1.6",
"karmabunny/rdb": "^1.31",
"karmabunny/router": "^2.7.12",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Sprout\Exceptions\HttpException;
use Sprout\Helpers\Errors;
use Sprout\Helpers\I18n;
use Sprout\Helpers\Request;
use Sprout\Helpers\Utf8;

ini_set('display_errors', '1');
Expand Down Expand Up @@ -87,13 +88,19 @@
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
}

// Hack in query params for CLI scripts.
if (PHP_SAPI === 'cli') {
$_GET = Request::getQueryParams();
}

require __DIR__ . '/bootstrap/config.php';

Utf8::setup();
I18n::init();

@mkdir(STORAGE_PATH . 'cache', 0755, true);
@mkdir(STORAGE_PATH . 'temp', 0755, true);
@mkdir(STORAGE_PATH . 'logs', 0755, true);

require __DIR__ . '/bootstrap/kohana.php';

Expand Down Expand Up @@ -121,6 +128,10 @@

ini_set('display_errors', Errors::$ENABLE_FATAL_ERRORS ? '0' : '1');

// TODO make this configurable.
ini_set('error_log', STORAGE_PATH . 'logs/php.log');
ini_set('log_errors', '1');

// Now that we have an exception handler - check for pre-execution errors.
if (isset($e0)) {
throw new ErrorException($e0['message'], 0, $e0['type'], $e0['file'], $e0['line']);
Expand All @@ -132,6 +143,9 @@
throw new HttpException($status, $error);
}

// Welcome system.
require __DIR__ . '/bootstrap/welcome.php';

// Bootstrap the application.
require APPPATH . 'core/Bootstrap.php';
return true;
require __DIR__ . '/bootstrap/app.php';
return true;
25 changes: 25 additions & 0 deletions src/bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/*
* Copyright (C) 2026 Karmabunny Pty Ltd.
*
* This file is a part of SproutCMS.
*
* SproutCMS is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation, either
* version 2 of the License, or (at your option) any later version.
*
* For more information, visit <http://getsproutcms.com>.
*/

use Sprout\Core\BaseApp;
use Sprout\Helpers\Config;

$app = Config::get('config.app');

if (!is_subclass_of($app, BaseApp::class)) {
throw new RuntimeException("Application must extend " . BaseApp::class);
}

// Boot up and go.
$instance = $app::instance();
$instance->run();
23 changes: 22 additions & 1 deletion src/bootstrap/kohana.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

use Sprout\Helpers\I18n;
use karmabunny\kb\Events;
use Sprout\App;
use Sprout\Events\PreControllerEvent;
use Sprout\Helpers\Request;
use Sprout\Helpers\Router;

// Backwards compat.
if (!defined('KOHANA')) {
Expand All @@ -25,7 +30,23 @@

Kohana::$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
Kohana::$locale = I18n::getLanguage();
Kohana::setup();

$_SERVER['HTTP_HOST'] ??= Kohana::config('config.cli_domain');
$_SERVER['SERVER_NAME'] ??= $_SERVER['HTTP_HOST'];

// Keep old router properties.
Router::$current_uri = Request::findUri();
Router::$query_string = '?' . Request::getQueryString(true);
Router::$complete_uri = Router::$current_uri . Router::$query_string;

Events::on(App::class, function(PreControllerEvent $event) {
Router::$controller = $event->controller;
Router::$method = $event->method;
Router::$arguments = $event->arguments;
});

// Remove the kohana query URI, if present.
if (isset($_GET['kohana_uri'])) {
unset($_GET['kohana_uri']);
$_SERVER['QUERY_STRING'] = preg_replace('~\bkohana_uri\b[^&]*+&?~', '', $_SERVER['QUERY_STRING']);
}
22 changes: 22 additions & 0 deletions src/bootstrap/welcome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/*
* Copyright (C) 2026 Karmabunny Pty Ltd.
*
* This file is a part of SproutCMS.
*
* SproutCMS is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation, either
* version 2 of the License, or (at your option) any later version.
*
* For more information, visit <http://getsproutcms.com>.
*/

use Sprout\Helpers\Modules;
use Sprout\Welcome\WelcomeApp;

// Mini version of framework when using the welcome system
// that avoids lots of code paths which use a database.
if ($welcome = Modules::getModule('Welcome')) {
$app = WelcomeApp::instance();
$app->run();
}
Loading