Skip to content

Commit

Permalink
Release: version 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fariz Luqman committed Jul 10, 2016
1 parent 618ae1e commit b52984f
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 27 deletions.
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
2 changes: 1 addition & 1 deletion src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @author Studio Nexus <[email protected]>
* @copyright 2016 Studio Nexus
* @license MIT
* @version Release: 0.1.0
* @version Release: 0.1.1
* @link https://www.studionexus.co/php/damnstupidsimple
*/
namespace Core;
Expand Down
6 changes: 3 additions & 3 deletions src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @author Studio Nexus <[email protected]>
* @copyright 2016 Studio Nexus
* @license MIT
* @version Release: 0.1.0
* @version Release: 0.1.1
* @link https://www.studionexus.co/php/damnstupidsimple
*/
namespace Core;
Expand Down Expand Up @@ -73,7 +73,7 @@ class Cache {
static function init(){

if(self::$config === null){
self::$config = require_once(DSS_PATH.'config/cache.php');
self::$config = Config::get('cache');
}

if(self::$config['enabled'] === true){
Expand All @@ -98,4 +98,4 @@ static function clean(){
CacheManager::clean();
}

}
}
109 changes: 109 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?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.1
* @link https://www.studionexus.co/php/damnstupidsimple
*/
namespace Core;

/**
* The Configuration Loader
* -----------------------------------------------------------------------
*
* The Configuration loader are responsible to read and return the
* configurations in a form of array.
*
* Usage:
* 1. Get the entire configuration from a file:
* $config = Config::get('filename');
*
* 2. Get specific configuration from a file:
* $config = Config::get('filename', 'configuration_key');
*
*/
class Config {

/**
* The array of configuration from config/env.php
* @var array
* @access protected
* @static
*/
protected static $env = null;

/**
* The array of configuration from files located on config directory
* @var array
* @access protected
* @static
*/
protected static $hive = null;

/**
* Link a variable or an object to the container
*
* @param string $file the configuration file name (without .php)
* @param string $key the array key
*
* @return array $hive the array of configurations
*
* @static
* @access public
* @since Method available since 0.1.1
*/
public static function get($file, $key = null){
if(isset(self::$hive[$file]) === false){
self::$hive[$file] = include_once(DSS_PATH.'config/'.$file.'.php');
}

if($key === null){
return self::$hive[$file];
}else{
return self::$hive[$file][$key];
}
}

/**
* Reads the configuration file (config/env.php) and include each of the
* variables (retrieved in a form of associative array) to the Environment
* Variable. Also store the configurations into static variable $env
*
* @static
* @access public
* @since Method available since Release 0.1.1
*/
public static function setEnv(){
if(self::$env === null){
self::$env = require_once(DSS_PATH.'config/env.php');
}

foreach(self::$env as $v => $a){
putenv($v.'='.$a);
}
}
}
6 changes: 3 additions & 3 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @author Studio Nexus <[email protected]>
* @copyright 2016 Studio Nexus
* @license MIT
* @version Release: 0.1.0
* @version Release: 0.1.1
* @link https://www.studionexus.co/php/damnstupidsimple
*/
namespace Core;
Expand Down Expand Up @@ -55,10 +55,10 @@ class Database extends Capsule{
* @access public
* @since Method available since Release 0.1.0
*/
static function connect(){
public static function connect(){

if(self::$config === null){
self::$config = include(DSS_PATH.'config/database.php');
self::$config = Config::get('database');
}

if(self::$config['enabled'] === true){
Expand Down
16 changes: 0 additions & 16 deletions src/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ static function display($name, $message = ''){
self::set_header('500', 'Internal Server Error');
include('errorpage/'. $name .'.php');
}

/**
* Reads the configuration file (config/env.php) and and include each of the
* variables (retrieved in a form of associative array) to the Environment
* Variable.
*
* @static
* @access public
* @since Method available since Release 0.1.0
*/
static function init_env(){
$var=require_once(DSS_PATH.'config/env.php');
foreach($var as $v => $a){
putenv($v.'='.$a);
}
}

/**
* Calculate a precise time difference.
Expand Down
4 changes: 2 additions & 2 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @copyright 2015 Noah Buscher
* @license https://github.com/noahbuscher/Macaw/blob/master/LICENSE.md MIT
* @link https://github.com/noahbuscher/Macaw
* @version Release: 0.1.0
* @version Release: 0.1.1
*/
namespace Core;

Expand Down Expand Up @@ -138,7 +138,7 @@ public static function dispatch(){
// Fix multi parameters
if(!method_exists($controller, $segments[1])) {
//"controller and action not found"
Debugger::report(500);
Debugger::report(500);
} else {
call_user_func_array(array($controller, $segments[1]), $matched);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sharer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @author Studio Nexus <[email protected]>
* @copyright 2016 Studio Nexus
* @license MIT
* @version Release: 0.1.0
* @version Release: 0.1.1
* @link https://www.studionexus.co/php/damnstupidsimple
*/
namespace Core;
Expand Down
88 changes: 88 additions & 0 deletions src/Singleton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?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.1
* @link https://www.studionexus.co/php/damnstupidsimple
*/
namespace Core;

/**
* The Singleton
* -----------------------------------------------------------------------
*
* Simply extends this Singleton class if you wish to use the Singleton
* pattern of programming in your project
*
*/
class Singleton {
private static $instances = array();

/**
* Constructor method
*
* @access protected
* @since Method available since Release 0.1.1
*/
protected function __construct() {
//
}

/**
* Avoid cloning
*
* @access protected
* @since Method available since Release 0.1.1
*/
protected function __clone() {
//
}

/**
* Avoid unserialization
*
* @access public
* @since Method available since Release 0.1.1
*/
public function __wakeup(){
throw new Exception("Cannot unserialize singleton");
}

/**
* Get the instance of desired class
*
* @access public
* @since Method available since Release 0.1.1
*/
public static function getInstance(){
$class = get_called_class(); // late-static-bound class name
if (!isset(self::$instances[$class])) {
self::$instances[$class] = new static;
}
return self::$instances[$class];
}
}
2 changes: 1 addition & 1 deletion src/Viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @author Studio Nexus <[email protected]>
* @copyright 2016 Studio Nexus
* @license MIT
* @version Release: 0.1.0
* @version Release: 0.1.1
* @link https://www.studionexus.co/php/damnstupidsimple
*/
namespace Core;
Expand Down

0 comments on commit b52984f

Please sign in to comment.