Skip to content

Commit

Permalink
Update entry scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustMiller committed Feb 5, 2024
1 parent c731e2b commit 3a4cc0e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 39 deletions.
18 changes: 18 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Shared bootstrap file
*/

// Define path constants
define('CRAFT_BASE_PATH', __DIR__);
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH . '/vendor');

// Load Composer's autoloader
require_once CRAFT_VENDOR_PATH . '/autoload.php';

// Load dotenv?
if (class_exists(Dotenv\Dotenv::class)) {
// By default, this will allow .env file values to override environment variables
// with matching names. Use `createUnsafeImmutable` to disable this.
Dotenv\Dotenv::createUnsafeMutable(CRAFT_BASE_PATH)->safeLoad();
}
30 changes: 5 additions & 25 deletions craft
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,11 @@
* Craft console bootstrap file
*/

use craft\helpers\App;
// Load shared bootstrap
require __DIR__ . '/bootstrap.php';

define('CRAFT_BASE_PATH', __DIR__);
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');

// Composer autoloader
require_once CRAFT_VENDOR_PATH.'/autoload.php';

// dotenv
if (file_exists(CRAFT_BASE_PATH.'/.env')) {
Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load();
}

define('CRAFT_STREAM_LOG', true);
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');

if ($storagePath = getenv('CRAFT_STORAGE_PATH')) {
define('CRAFT_STORAGE_PATH', $storagePath);
}

if ($ephemeral = getenv('CRAFT_EPHEMERAL')) {
define('CRAFT_EPHEMERAL', filter_var($ephemeral, FILTER_VALIDATE_BOOL));
}

// Craft
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/console.php';
// Load and run Craft
/** @var craft\console\Application $app */
$app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/console.php';
$exitCode = $app->run();
exit($exitCode);
18 changes: 4 additions & 14 deletions web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,10 @@
* Craft web bootstrap file
*/

// Set path constants
define('CRAFT_BASE_PATH', dirname(__DIR__));
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');

// Load Composer's autoloader
require_once CRAFT_VENDOR_PATH.'/autoload.php';

// Load dotenv?
if (file_exists(CRAFT_BASE_PATH.'/.env')) {
Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load();
}

define('CRAFT_ENVIRONMENT', getenv('CRAFT_ENVIRONMENT') ?: 'production');
// Load shared bootstrap
require dirname(__DIR__) . '/bootstrap.php';

// Load and run Craft
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
/** @var craft\web\Application $app */
$app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/web.php';
$app->run();

0 comments on commit 3a4cc0e

Please sign in to comment.