Skip to content

Commit

Permalink
docu and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bakeiro committed Jan 6, 2020
1 parent 9403c90 commit 95c2085
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

**Create your API/Web app immediately!**

Extreme fast, simplest, and light php framework!
Light-PHP makes possible to start working without reading massive documentations, if this is the case, then Light-PHP might be very useful for you.
This was created to be the most simple framework to read/understand.

This project follows the PSR-0, PSR-1 and PSR-4 standards, good practices, MVC structure, micro template engine, database abstraction, session management, debug console (for PHP), and much more!.
This project follows the PSR-0, PSR-1 and PSR-4 standards, good practices, MVC structure it has security implementations, micro template engine, database abstraction, session management, debug console (for PHP), and much more!.

### Minimum requirements

Expand Down
4 changes: 2 additions & 2 deletions post-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
require_once "./system/library/Util.php";
$config_string = file_get_contents('./config.rename.php');

$token_iv = Util::generateSimpleToken(16);
$token_iv = Library\Util::generateSimpleToken(16);
$config_string = str_replace("ThisIsMySecretIv", $token_iv, $config_string);

$token_pass = Util::generateSimpleToken(32);
$token_pass = Library\Util::generateSimpleToken(32);
$config_string = str_replace("ThisIsMySecretPass", $token_pass, $config_string);

file_put_contents('./config.rename.php', $config_string);
Expand Down
2 changes: 1 addition & 1 deletion src/view/template/common/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Library\Config;

if (Config::Get("debug_console")) {
if (Config::get("debug_console")) {
include VIEW . "template/common/Console.php";
}
?>
Expand Down
4 changes: 2 additions & 2 deletions src/view/template/common/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<title>Light PHP</title>

<!-- Variables -->
<?php $cache = Config::Get("cache_version"); ?>
<?php $host = Config::Get("url_host"); ?>
<?php $cache = Config::get("cache_version"); ?>
<?php $host = Config::get("url_host"); ?>

<!-- my resources -->
<link href="src/view/www/dist/src.css?v=<?=$cache?>" rel="stylesheet">
Expand Down
7 changes: 7 additions & 0 deletions system/engine/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function __construct($route)

/**
* Executes the controller
*
* @return void
*/
public function execController()
{
Expand All @@ -43,6 +45,11 @@ public function execController()
$controller_class->$method();
}

/**
* Executes the model function and returns the json to the client
*
* @return void
*/
public function execRest()
{
$this->checkController();
Expand Down
16 changes: 12 additions & 4 deletions system/engine/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ class Router
public $controller;
public $restController;

/**
* Construct
*
* @return void
*/
public function __construct()
{
// Host
$url_host = 'http://';
if (isset($_SERVER['HTTPS'])) {
$url_host = 'https://';
}
$url_host .= $_SERVER['HTTP_HOST'];

// Protocol
$url_protocol = "http";
if (isset($_SERVER['HTTPS'])) {
$url_protocol = "https";
}

// Action
$url_action = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
$rest_controller = null;

// Controller
if (isset($_REQUEST['route']) && !isset($_REQUEST['rest'])) {
$url_controller = $_REQUEST['route'];
}
Expand All @@ -46,6 +47,13 @@ public function __construct()
$this->restController = $rest_controller;
}

/**
* Executes the function associated in the SEO url
*
* @param string $url_action seo url to search
*
* @return string
*/
public function getSeoUrlMethod($url_action)
{
include SYSTEM . "routes.php";
Expand Down
15 changes: 15 additions & 0 deletions system/engine/SessionSecureHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ class SessionSecureHandler extends SessionHandler

/**
* Constructor
*
* @param string $session_iv session iv
* @param string $session_key session key
* @param string $session_encrypt_method session encrypt method
*
* @return void
*/
public function __construct($session_iv, $session_key, $session_encrypt_method)
{
Expand All @@ -18,6 +24,10 @@ public function __construct($session_iv, $session_key, $session_encrypt_method)

/**
* Read the encrypted values
*
* @param string $session_id session id to read the values
*
* @return array
*/
public function read($session_id)
{
Expand All @@ -28,6 +38,11 @@ public function read($session_id)

/**
* Encrypt and save session values
*
* @param string $session_id session to write in the information
* @param string $data data to write into the session id
*
* @return array
*/
public function write($session_id, $data)
{
Expand Down
2 changes: 1 addition & 1 deletion system/library/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function addError($error)
}

/**
*
*
*/
public static function addWarning($warning)
{
Expand Down
12 changes: 6 additions & 6 deletions system/library/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public static function load($route, $data = array())
* the template as String
*
* @param string $route route of the template to load
* @param array $data Array with values to print in the template
* @param array $data Array with values to print in the template
*
* @return string template
*/
public static function loadFile($route, $data)
{
ob_start();
require $route;
include $route;
$template = ob_get_clean();

$template = Output::compile($template, $data);
Expand All @@ -53,12 +53,12 @@ public static function loadFile($route, $data)
* Adds a js file at the end of the html document
*
* @param string $js_route path of the js file (without extension)
*
*
* @return void
*/
public static function addJs($js_route)
{
$output_script = "<script src='src/view/www/dist/" . $js_route . ".js?v=" . Config::Get("cache_version") . "' > </script>";
$output_script = "<script src='src/view/www/dist/" . $js_route . ".js?v=" . Config::get("cache_version") . "' > </script>";
Output::$output_scripts[] = $output_script;
}

Expand All @@ -71,15 +71,15 @@ public static function addJs($js_route)
*/
public static function addCss($css_route)
{
$output_style = "<link href='src/view/www/dist/" . $css_route . ".css?v=" . Config::Get("cache_version") . "' rel='stylesheet'>";
$output_style = "<link href='src/view/www/dist/" . $css_route . ".css?v=" . Config::get("cache_version") . "' rel='stylesheet'>";
Output::$output_styles[] = $output_style;
}

/**
* Replaces the double brackets by the value in the $data Array
*
* @param string $template path of the template to import
* @param array $data Array of data to replace in the template
* @param array $data Array of data to replace in the template
*
* @return string
*/
Expand Down

0 comments on commit 95c2085

Please sign in to comment.