diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/app/config/bootstrap.php | 62 | ||||
| -rw-r--r-- | public/app/config/setup_application.php (renamed from public/app/config/setup-application.php) | 0 | ||||
| -rw-r--r-- | public/app/config/setup_framework.php (renamed from public/app/config/setup-framework.php) | 9 | ||||
| -rw-r--r-- | public/index.php | 19 |
4 files changed, 79 insertions, 11 deletions
diff --git a/public/app/config/bootstrap.php b/public/app/config/bootstrap.php new file mode 100644 index 0000000..a51272e --- /dev/null +++ b/public/app/config/bootstrap.php @@ -0,0 +1,62 @@ +<?php + +/** initialize System + * ----------------------------------------------------------------------------- + * + * Finalalize the MVC framework and construct the central objects + * (Registry and Request) + * + * Include _anything_ that is common practice on the request life-cycle + * of your project and does not need to be shown in the /public/index.php + * Usualy here you shall initialize supplamentary services like Sessions + * / Database / Caching etc. + * + * NOTE: + * Always try to keep the app as light as possible, so load only what is + * critical for the MVC to operate; + * anything else can be injected on-demand + * + * ----------------------------------------------------------------------------- + */ + +// setup error-handliing +// ----------------------------------------------------------------------------- +require_once APP_ROOT.'/core/helpers/error_handling.php'; + + + +// Setup Application Engiine +// ----------------------------------------------------------------------------- +// Setup supplementary services (derectry or as promises/vows) +// Session, Database, Caching + + +// Attache database to the Regostry a vow +Registry::vow('database', function() { return new Database(); }); + + +// Attach Cache to the Resitry as a vow +// (CACHE_DRIVER) acts as driver-wrapper +// --- -- -- - - - +Registry::vow('cache', function() { return new (CACHE_DRIVER)(); }); +// CHECK: if strict mode has any benefits: +// Registry::vow('cache', function():Cache_interface { return new (CACHE_DRIVER)(); }); + + +// Initialize THE REQUEST +// ----------------------------------------------------------------------------- +Registry::set('REQUEST', new Request()); + + + +// load design-patterns +// (these patterns use some of the project's central objects (Registry, +// Cache, Database), so laod them after. +// ----------------------------------------------------------------------------- +require_once APP_ROOT.'/core/helpers/design_patterns.php'; + + +// Add Routes +// ----------------------------------------------------------------------------- + +require_once WEB_ROOT.'/app/config/init_routes.php'; // initialize routes diff --git a/public/app/config/setup-application.php b/public/app/config/setup_application.php index ec9a7bb..ec9a7bb 100644 --- a/public/app/config/setup-application.php +++ b/public/app/config/setup_application.php diff --git a/public/app/config/setup-framework.php b/public/app/config/setup_framework.php index 63eb486..69c3402 100644 --- a/public/app/config/setup-framework.php +++ b/public/app/config/setup_framework.php @@ -16,6 +16,8 @@ * You may rewrite the defines setting any values manualy; * SETTING anom CONSTANTS VIA an `.env` FILE IS HIGHLY RECOMMENDED; * The default `.env` file is saved into project's root + * + * Blueprint: * * ----------------------------------------------------------------------------- */ @@ -101,8 +103,9 @@ define('SITE_URL', $env['ANOM_HOSTNAME']); define('URL_ROOT', '/'); -define('INIT_APPLICATION', APP_ROOT.'/core/config/init.php'); - +// main initialization script +define('APPLICATION_BOOTSTRAP', WEB_ROOT.'/app/config/bootstrap.php'); + define('VIEWS_DIRECTORY', $env['VIEWS_DIRECTORY'] ?? (WEB_ROOT.'/app/views/')); define('TESTS_DIRECTORY', $env['TESTS_DIRECTORY'] ?? (APP_ROOT."/tests/")); @@ -466,4 +469,4 @@ define('PROXY_DO_NOT_CACHE', 4); // do not cache result * * ----------------------------------------------------------------------------- */ -require_once WEB_ROOT.'/app/config/setup-application.php';
\ No newline at end of file +require_once WEB_ROOT.'/app/config/setup_application.php'; diff --git a/public/index.php b/public/index.php index 5c84e97..9dea217 100644 --- a/public/index.php +++ b/public/index.php @@ -2,23 +2,26 @@ /** anom * ANOther MVC framefork /////////////////////////////////////////////////////// * ----------------------------------------------------------------------------- + * * This is where the whole thing stats. * Let's keep it simple and clear * - * anom is an Object-Oriented MVC php-framework. - * It is super-light, fast and extensible. - * Contains almost anything you need to start - * and optimize a server-based web-application. + * anom is an(other) Object-Oriented MVC php-framework. + * It is a super-light, fast and extensible development + * tool. + * + * Contains implementations of almost anything you need + * to start and optimize a server-based web-application. * And as long as you write code using secure practices, - * it will be secure. + * it shall be secure. * * Copyleft: George Halkiadakis * Licence: BSD + * * \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ * ----------------------------------------------------------------------------- */ - // specify base paths // ----------------------------------------------------------------------------- @@ -35,7 +38,7 @@ define('WEB_ROOT', APP_ROOT.'/'.$pub); // root of public directory // contants and constant arrays // ----------------------------------------------------------------------------- -require_once WEB_ROOT.'/app/config/setup-framework.php'; // application constants +require_once WEB_ROOT.'/app/config/setup_framework.php'; // application constants @@ -62,7 +65,7 @@ if (!PRODUCTION) Benchmark::add_spot('start'); // benchmark request's life // finalize framework; handle credentials; setup app-engine; insert routes // ----------------------------------------------------------------------------- -require_once INIT_APPLICATION; +require_once APPLICATION_BOOTSTRAP; // Application is ready! |
