-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feb 15, 2017
0 parents
commit 9d7dea2
Showing
16 changed files
with
1,676 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,3 @@ | ||
# Always use LF | ||
* text eol=lf | ||
*.hh linguist-language=Hack |
Empty file.
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,21 @@ | ||
{ | ||
"name": "stupidlysimple/hack-core", | ||
"description": "Core packages for StupidlySimple Hack Framework", | ||
"keywords": ["micro framework","lazy","stupidly simple", "hack framework", "hack", "hhvm"], | ||
"type": "project", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Fariz Luqman", | ||
"email": "[email protected]", | ||
"homepage": "https://stupidlysimple.github.io", | ||
"role": "Developer" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"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,3 @@ | ||
# Always use LF | ||
* text eol=lf | ||
*.hh linguist-language=Hack |
Empty file.
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,58 @@ | ||
<?hh | ||
/** | ||
* StupidlySimple Framework for Hack - A Framework For Hack-ers | ||
* | ||
* Copyright (c) 2017 Fariz Luqman | ||
* | ||
* 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 StupidlySimple Framework for Hack | ||
* @author Fariz Luqman <[email protected]> | ||
* @copyright 2017 Fariz Luqman | ||
* @license MIT | ||
* @since 0.1.0 | ||
* @link https://stupidlysimple.github.io/hack/ | ||
*/ | ||
namespace Core; | ||
/** | ||
* The Alias Manager | ||
* ----------------------------------------------------------------------- | ||
* | ||
* Register the array of class aliases when this application | ||
* is started. | ||
* | ||
*/ | ||
class Alias { | ||
static private $config = null; | ||
/** | ||
* Reads the configuration file (config/aliases.php) and create the | ||
* alias | ||
* | ||
* @static | ||
* @since Method available since release 0.2.0 | ||
*/ | ||
static function init() : void { | ||
if(self::$config === null){ | ||
self::$config = Config::get('aliases'); | ||
} | ||
foreach(self::$config as $class => $alias){ | ||
class_alias($class, $alias); | ||
} | ||
} | ||
} |
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,46 @@ | ||
<?hh | ||
/** | ||
* StupidlySimple Framework for Hack - A Framework For Hack-ers | ||
* | ||
* Copyright (c) 2017 Fariz Luqman | ||
* | ||
* 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 StupidlySimple Framework for Hack | ||
* @author Fariz Luqman <[email protected]> | ||
* @copyright 2017 Fariz Luqman | ||
* @license MIT | ||
* @since 0.1.0 | ||
* @link https://stupidlysimple.github.io/hack/ | ||
*/ | ||
namespace Core\App; | ||
/** | ||
* 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 extends AppAbstract { | ||
public function link (string $var_name, $val) : void { | ||
$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,35 @@ | ||
<?hh | ||
/** | ||
* StupidlySimple Framework for Hack - A Framework For Hack-ers | ||
* | ||
* Copyright (c) 2017 Fariz Luqman | ||
* | ||
* 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 StupidlySimple Framework for Hack | ||
* @author Fariz Luqman <[email protected]> | ||
* @copyright 2017 Fariz Luqman | ||
* @license MIT | ||
* @since 0.1.0 | ||
* @link https://stupidlysimple.github.io/hack/ | ||
*/ | ||
namespace Core\App; | ||
abstract class AppAbstract { | ||
abstract public function link (string $var_name, $val) : void; | ||
} |
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,103 @@ | ||
<?hh | ||
/** | ||
* StupidlySimple Framework for Hack - A Framework For Hack-ers | ||
* | ||
* Copyright (c) 2017 Fariz Luqman | ||
* | ||
* 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 StupidlySimple Framework for Hack | ||
* @author Fariz Luqman <[email protected]> | ||
* @copyright 2017 Fariz Luqman | ||
* @license MIT | ||
* @since 0.1.0 | ||
* @link https://stupidlysimple.github.io/hack/ | ||
*/ | ||
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(string $file, string $key = '') : array { | ||
if(isset(self::$hive[$file]) === false){ | ||
self::$hive[$file] = include_once(SS_PATH.'config/'.$file.'.hh'); | ||
} | ||
if($key === ''){ | ||
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 | ||
* @return void | ||
*/ | ||
public static function setEnv() : void { | ||
if(self::$env === null){ | ||
self::$env = require_once(SS_PATH.'config/env.hh'); | ||
} | ||
foreach(self::$env as $v => $a){ | ||
putenv($v.'='.$a); | ||
} | ||
} | ||
} |
Oops, something went wrong.