-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fariz Luqman
committed
Jul 2, 2016
1 parent
1217b8e
commit 09d141a
Showing
13 changed files
with
923 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "damnstupidsimple/core", | ||
"description": "The core package for Damn Stupid Simple framework", | ||
"keywords": ["micro framework","lazy","damn stupid simple"], | ||
"license": "MIT", | ||
"type": "project", | ||
"authors": [{ | ||
"name": "Studio Nexus", | ||
"email": "[email protected]", | ||
"homepage": "https://www.studionexus.co", | ||
"role": "Developer" | ||
}], | ||
"config": { | ||
"vendor-dir": "vendor" | ||
}, | ||
"require": { | ||
"php": ">=5.4.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Core\\": "src" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Damn Stupid Simple - A PHP Framework For Lazy Developers | ||
* | ||
* Copyright (c) 2016 Studio Nexus | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* @package Damn Stupid Simple | ||
* @author Studio Nexus <[email protected]> | ||
* @copyright 2016 Studio Nexus | ||
* @license MIT | ||
* @version Release: 0.1.0 | ||
* @link https://www.studionexus.co/php/damnstupidsimple | ||
*/ | ||
namespace Core; | ||
|
||
/** | ||
* The Application Container | ||
* ----------------------------------------------------------------------- | ||
* | ||
* Containers are used for dependency injection, which allows us to reduce | ||
* coupling. It is a rather simple piece of code, but it is powerful. | ||
* | ||
*/ | ||
class App { | ||
|
||
/** | ||
* Link a variable or an object to the container | ||
* | ||
* @param mixed $var_name variable name that we want to register | ||
* @param mixed $val the value/array/object | ||
*/ | ||
function link($var_name, $val){ | ||
$this->$var_name = $val; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
/** | ||
* Damn Stupid Simple - A PHP Framework For Lazy Developers | ||
* | ||
* Copyright (c) 2016 Studio Nexus | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* @package Damn Stupid Simple | ||
* @author Studio Nexus <[email protected]> | ||
* @copyright 2016 Studio Nexus | ||
* @license MIT | ||
* @version Release: 0.1.0 | ||
* @link https://www.studionexus.co/php/damnstupidsimple | ||
*/ | ||
namespace Core; | ||
use phpFastCache\CacheManager as CacheManager; | ||
|
||
/** | ||
* The Cache Facade | ||
* ----------------------------------------------------------------------- | ||
* | ||
* The Cache Facade configures the Cache Manager and provides access to the | ||
* Cache Manager instance | ||
* | ||
*/ | ||
class Cache { | ||
|
||
/** | ||
* The instance of phpFastCache\CacheManager | ||
* @var object | ||
* @access private | ||
* @static | ||
*/ | ||
static private $CacheManager = null; | ||
|
||
/** | ||
* The configurations | ||
* @var array | ||
* @access private | ||
* @static | ||
*/ | ||
static private $config = null; | ||
|
||
/** | ||
* Create and return the instance of phpFastCache\CacheManager | ||
* | ||
* @return object the instance of the Cache Manager if cache enabled | ||
* in the configuration file (config/cache.php), null | ||
* if disabled | ||
* | ||
* @static | ||
* @see Cache::clean() | ||
* @access public | ||
* @since Method available since Release 0.1.0 | ||
*/ | ||
static function init(){ | ||
|
||
if(self::$config === null){ | ||
self::$config = require_once(DSS_PATH.'config/cache.php'); | ||
} | ||
|
||
if(self::$config['enabled'] === true){ | ||
CacheManager::setup(self::$config['settings']); | ||
if(self::$CacheManager === null){ | ||
self::$CacheManager = CacheManager::getInstance(); | ||
} | ||
return self::$CacheManager; | ||
}else{ | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Clear all cached data | ||
* | ||
* @static | ||
* @access public | ||
* @since Method available since Release 0.1.0 | ||
*/ | ||
static function clean(){ | ||
CacheManager::clean(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* Damn Stupid Simple - A PHP Framework For Lazy Developers | ||
* | ||
* Copyright (c) 2016 Studio Nexus | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* @package Damn Stupid Simple | ||
* @author Studio Nexus <[email protected]> | ||
* @copyright 2016 Studio Nexus | ||
* @license MIT | ||
* @version Release: 0.1.0 | ||
* @link https://www.studionexus.co/php/damnstupidsimple | ||
*/ | ||
namespace Core; | ||
use Illuminate\Database\Capsule\Manager as Capsule; | ||
|
||
/** | ||
* The Database Facade | ||
* ----------------------------------------------------------------------- | ||
* | ||
* The Cache Facade configures the Cache Manager and provides access to the | ||
* Cache Manager instance | ||
* | ||
*/ | ||
class Database extends Capsule{ | ||
static private $config = null; | ||
static private $capsule; | ||
|
||
/** | ||
* Create and return the instance of Illuminate\Database\Capsule\Manager | ||
* | ||
* @return object the instance of the Capsule if database enabled | ||
* in the configuration file (config/database.php), null | ||
* if disabled | ||
* | ||
* @static | ||
* @access public | ||
* @since Method available since Release 0.1.0 | ||
*/ | ||
static function connect(){ | ||
|
||
if(self::$config === null){ | ||
self::$config = include(DSS_PATH.'config/database.php'); | ||
} | ||
|
||
if(self::$config['enabled'] === true){ | ||
$capsule = new Capsule; | ||
$capsule->addConnection(self::$config['settings']); | ||
$capsule->bootEloquent(); | ||
$capsule->setAsGlobal(); | ||
self::$capsule = $capsule; | ||
return self::$capsule; | ||
}else{ | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.