Files
namaste/config/sneakerstrap.inc
gramps 373ebc8c93 Archive: Namaste PHP AMQP framework v1.0 (2017-2020)
952 days continuous production uptime, 40k+ tp/s single node.
Original corpo Bitbucket history not included — clean archive commit.
2026-04-05 09:49:30 -07:00

86 lines
2.9 KiB
PHP

<?php
define('PHP_MINIMUM_VERSION', 70401);
/**
* sneakerstrap.inc
*
* This is a light-version of the bootstrap.inc file. It is for Namaste *clients* to use when connecting to the
* framework and when they need access to Namaste constants, functions, and resources.
*
* This file omits the static-class instantiations which saves significant amounts of time for the client(s).
*
*
* @author mike@givingassistant.org
* @version 1.0.0
*
*
* HISTORY:
* ========
* 08-29-18 mks DB-59: original coding
* 09-02-18 mks DB-43: Parse exception-handling wrappers around require statements
* 05-23-19 mks DB-116: Work-around patch for array_key_first() method
* 01-17-20 mks DB-150: enforcing minimum PHP version
*
*/
$eos = (isset($_SERVER['HTTP_USER_AGENT'])) ? '<br />' : PHP_EOL;
$topDir = dirname( __DIR__ );
// add a version check for php
if (PHP_VERSION_ID < PHP_MINIMUM_VERSION) exit ('A version of PHP >= 7.4.1 is required to run Namaste.' . PHP_EOL);
function gt(): string
{
return('[' . date("d/m/y@H:i:s", time()) . '] [ !]STRP: ');
}
// load the files stored in the common directory
foreach(glob($topDir . '/common/*.php') as $filename) {
try {
/** @noinspection PhpIncludeInspection */
require_once($filename);
} catch (ParseError $p) {
echo gt() . 'Caught parse exception in ' . $filename . PHP_EOL;
echo gt() . $p->getMessage() . PHP_EOL;
exit(1);
}
}
$classesDir = $topDir . DIR_CLASSES;
$configDir = $topDir . DIR_CONFIG;
$amqpLib = $topDir . DIR_LIB;
$templateDir = $topDir . DIR_CLASSES . DIR_TEMPLATE;
// load the auto-loaders (composer and namaste)
try {
/** @noinspection PhpIncludeInspection */
require($topDir . FILE_AUTOLOADER);
} catch (ParseError $p) {
echo gt() . 'Caught parse exception in ' . $filename . PHP_EOL;
echo gt() . $p->getMessage() . PHP_EOL;
exit(1);
}
if(file_exists($classesDir)) {
Autoloader::register_directory($classesDir);
Autoloader::register_directory($templateDir);
}
try {
require_once $amqpLib . '/vendor/autoload.php';
} catch (ParseError $p) {
echo gt() . 'Caught parse exception in ' . $filename . PHP_EOL;
echo gt() . $p->getMessage() . PHP_EOL;
exit(1);
}
use /** @noinspection PhpUnusedAliasInspection */ PhpAmqpLib\Connection\AMQPStreamConnection;
use /** @noinspection PhpUnusedAliasInspection */ PhpAmqpLib\Channel\AMQPChannel;
use /** @noinspection PhpUnusedAliasInspection */ PhpAmqpLib\Message\AMQPMessage;
// load the base configuration
if (!gasConfig::singleton($configDir . FILE_BASE_CONFIG, FILE_TYPE_XML))
exit(gt() . 'Failed to load config singleton...' . $eos);
if (file_exists($configDir . FILE_ENV_CONFIG)) {
gasConfig::addConfig($configDir . FILE_ENV_CONFIG, FILE_TYPE_XML);
if (!gasConfig::$status)
exit(gt() . 'Failed to load/layer env configuration...' . $eos);
}
// load the cache handler because it's fast
if (!isset(gasCache::$available)) gasCache::singleton();