Skip to content
This repository was archived by the owner on Feb 1, 2026. It is now read-only.

Commit f3ec80f

Browse files
committed
add new bootstrap script; leverage new global var names
global vars now use ERDIKO_ to namespace theme (avoid potential collisions with other libraries)
1 parent 27971b6 commit f3ec80f

File tree

13 files changed

+46
-27
lines changed

13 files changed

+46
-27
lines changed

src/AjaxController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AjaxController extends Controller
2525
*/
2626
public function __construct()
2727
{
28-
$this->_webroot = ROOT;
28+
$this->_webroot = ERDIKO_ROOT;
2929
$this->_response = new \erdiko\core\AjaxResponse;
3030
}
3131

src/ApiController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ApiController extends Controller
2626
*/
2727
public function __construct()
2828
{
29-
$this->_webroot = ROOT;
29+
$this->_webroot = ERDIKO_ROOT;
3030
$this->_response = new \erdiko\core\ApiResponse;
3131
}
3232

src/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Controller
3333
*/
3434
public function __construct()
3535
{
36-
$this->_webroot = ROOT;
36+
$this->_webroot = ERDIKO_ROOT;
3737
$this->_response = new \erdiko\core\Response;
3838

3939
if ($this->_themeName != null) {

src/Helper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function getConfig($name = 'application', $context = null)
6767
if($context == null)
6868
$context = getenv('ERDIKO_CONTEXT');
6969

70-
$filename = APPROOT."/config/{$context}/{$name}.json";
70+
$filename = ERDIKO_APP."/config/{$context}/{$name}.json";
7171
return self::getConfigFile($filename);
7272
}
7373

@@ -80,7 +80,7 @@ public static function getRoutes($context = null)
8080
{
8181
if($context == null)
8282
$context = getenv('ERDIKO_CONTEXT');
83-
$file = APPROOT."/config/{$context}/routes.json";
83+
$file = ERDIKO_APP."/config/{$context}/routes.json";
8484
$applicationConfig = self::getConfigFile($file);
8585

8686
return $applicationConfig['routes'];
@@ -115,11 +115,11 @@ public static function log($level, $message, array $context = array())
115115
if(self::$_logObject==null)
116116
{
117117
$erdikoContext = getenv('ERDIKO_CONTEXT');
118-
$config = self::getConfig("{$erdikoContext}/application");
118+
$config = self::getConfig("application", $erdikoContext);
119119
$logFiles = $config["logs"]["files"][0];
120120
$logDir = $config["logs"]["path"];
121121

122-
self::$_logObject = new erdiko\core\Logger($logFiles, $logDir);
122+
self::$_logObject = new \erdiko\core\Logger($logFiles, $logDir);
123123
}
124124

125125
if(empty($level))

src/Logger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public function __construct($logFiles = array(), $logDir = null)
4646
if (is_dir($logDir)) {
4747
$this->_filePath = $logDir; // fully qualified & valid path
4848
} else {
49-
$this->_filePath = \ROOT.$logDir; // otherwise assume it's relative to the root
49+
$this->_filePath = \ERDIKO_ROOT.$logDir; // otherwise assume it's relative to the root
5050
}
5151
} else {
52-
$this->_filePath = \ROOT.$this->_defaultPath;
52+
$this->_filePath = \ERDIKO_ROOT.$this->_defaultPath;
5353
}
5454
}
5555

src/Template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait Template
3131
* @param string $template , Theme Object (Contaier)
3232
* @param mixed $data
3333
*/
34-
public function initiate($template = null, $data = null, $templateRootFolder = APPROOT)
34+
public function initiate($template = null, $data = null, $templateRootFolder = ERDIKO_APP)
3535
{
3636
$template = ($template === null) ? $this->getDefaultTemplate() : $template;
3737
$this->setTemplate($template);

src/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class View extends Container
2020
* @param mixed $data
2121
* @param string $templateFolder
2222
*/
23-
public function __construct($template = null, $data = null, $templateRootFolder = APPROOT)
23+
public function __construct($template = null, $data = null, $templateRootFolder = ERDIKO_APP)
2424
{
2525
$this->initiate($template, $data, $templateRootFolder);
2626
$this->setTemplateFolder('views');

src/autoload.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* @author John Arroyo, john@arroyolabs.com
99
*/
1010

11-
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . ROOT .
12-
PATH_SEPARATOR . VENDOR . PATH_SEPARATOR . APPROOT . PATH_SEPARATOR . ERDIKO);
11+
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . ERDIKO_ROOT .
12+
PATH_SEPARATOR . ERDIKO_VENDOR . PATH_SEPARATOR . ERDIKO_APP . PATH_SEPARATOR . ERDIKO_SRC);
1313

1414

1515
spl_autoload_register(function ($name) {
@@ -20,7 +20,7 @@
2020
$path = str_replace('\\', '/', $name);
2121
$class = basename($path);
2222
$dir = '/'.dirname($path);
23-
$filename = ROOT.$dir.'/'.$class.'.php';
23+
$filename = ERDIKO_ROOT.$dir.'/'.$class.'.php';
2424
// error_log("file: $filename");
2525

2626
if (is_file($filename)) {

src/bootstrap.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
define('ERDIKO_PUBLIC', ERDIKO_ROOT.'/public');
3+
define('ERDIKO_APP', ERDIKO_ROOT.'/app');
4+
define('ERDIKO_VAR', ERDIKO_ROOT.'/var');
5+
define('ERDIKO_VIEWS', APPROOT.'/views/');
6+
7+
// Composer
8+
require_once ERDIKO_VENDOR.'/autoload.php';
9+
10+
// Core
11+
require_once ERDIKO_SRC.'/Toro.php';
12+
require_once ERDIKO_SRC.'/autoload.php'; // auto loading for the app
13+
14+
// Core framework functions (static functions)
15+
require_once ERDIKO_ROOT.'/Erdiko.php';
16+
17+
// Set a default context if none specified
18+
if(empty(getenv('ERDIKO_CONTEXT')))
19+
putenv("ERDIKO_CONTEXT=default");

src/cache/File.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class File extends \erdiko\core\datasource\File implements CacheInterface
1919
public function __construct($cacheDir = null)
2020
{
2121
if (!isset($cacheDir)) {
22-
$cacheDir = VARROOT."/cache";
22+
$cacheDir = ERDIKO_VAR."/cache";
2323
}
2424
parent::__construct($cacheDir);
2525
}
@@ -83,7 +83,7 @@ public function forget($key)
8383
*/
8484
public function forgetAll()
8585
{
86-
$files = glob(VARROOT."/cache/*");
86+
$files = glob(ERDIKO_VAR."/cache/*");
8787
foreach ($files as $file) {
8888
if (is_file($file)) {
8989
$this->delete(basename($file));

0 commit comments

Comments
 (0)