18 Commits

Author SHA1 Message Date
a7380841cf Move concerns to right places 2020-12-15 22:02:02 +01:00
28dd69e3a5 Write concerns 2020-12-15 21:55:39 +01:00
f21293bc01 Remove test code 2020-12-15 21:50:42 +01:00
bf79e9cee7 Introduced configurations and application object (test code) 2020-12-15 21:46:46 +01:00
cf30a1280d Really basic application object. 2020-12-15 21:10:42 +01:00
e11023d1c9 Merge pull request 'feature/composer' (#1) from feature/composer into remastering
Reviewed-on: #1
2020-12-15 16:10:30 +00:00
cfcfefefd8 Bootstrap installed 2020-12-15 16:59:08 +01:00
09d78192b6 Use composer autoload.php instead of custom boostrap.php 2020-12-15 16:56:12 +01:00
158220700b Create composer.json, ignore vendor/ folder. 2020-12-15 16:54:29 +01:00
GamerClassN7
76e036181a Docker submodule fixed 2020-12-15 09:13:23 +01:00
GamerClassN7
39f44c8d03 api tweeks 2020-12-15 09:07:47 +01:00
Haitem
ee0ebff76a first part of plugin setting 2020-12-09 14:30:41 +01:00
42443c8b58 Fix 2020-12-09 12:42:26 +01:00
e95435a707 Better settings Manager 2020-12-09 12:36:57 +01:00
74f6779c63 Fix 2020-12-09 12:28:31 +01:00
181a65a99b Bug Fixes 2020-12-09 12:19:19 +01:00
GamerClassN7
ff2c51d505 Minor Tweeks 2020-12-07 20:21:27 +01:00
GamerClassN7
879a63948f Bugfix 2020-11-30 12:37:44 +01:00
26 changed files with 455 additions and 62 deletions

3
.gitignore vendored
View File

@@ -15,3 +15,6 @@ _nemazat/css/font-awesome.min.css
app/updater/*.bin app/updater/*.bin
app/logs/*.log app/logs/*.log
backup/*.zip backup/*.zip
vendor/

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule ".docker"]
path = .docker
url = https://github.com/GamerClassN7/Docker-Xamp-Server.git

View File

@@ -5,11 +5,20 @@ ini_set( 'display_errors','1');
//setup //setup
parse_str($_SERVER['QUERY_STRING'], $params); parse_str($_SERVER['QUERY_STRING'], $params);
$urlSes = str_replace((!empty ($params['url']) ? $params['url'] : ""), "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI'])); if (defined ("BASEDIR")) {
$urlSes = BASEDIR;
} else {
$urlSes = str_replace((!empty ($params['url']) ? $params['url'] : ""), "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI']));
}
if (defined ("BASEDIR") && defined ("BASEURL")) {
$domain = str_replace("http://", "", str_replace("https://", "", str_replace(BASEDIR, "", BASEURL)));
} else {
$domain = str_replace("/var/www/", "", $_SERVER['DOCUMENT_ROOT']);
}
session_set_cookie_params( session_set_cookie_params(
1209600, 1209600,
$urlSes, $urlSes,
str_replace("/var/www/", "", $_SERVER['DOCUMENT_ROOT']), $domain,
true, true,
true true
); );

View File

@@ -18,38 +18,49 @@ class RoomsApi extends ApiController
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds); $subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
foreach ($subDevicesData as $subDeviceKey => $subDevice) { foreach ($subDevicesData as $subDeviceKey => $subDevice) {
foreach ($subDevice as $key => $value) { foreach ($subDevice as $key => $value) {
//Type Handling
$type = null; $type = null;
if (strpos($subDevicesData[$subDeviceKey][$key]['type'], '-') !== false) { if (strpos($subDevicesData[$subDeviceKey][$key]['type'], '-') !== false) {
$type = $subDevicesData[$subDeviceKey][$key]['type']; $type = $subDevicesData[$subDeviceKey][$key]['type'];
} else if (strpos(SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'], '-') !== false) { } else if (strpos(SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'], '-') !== false) {
$type = SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type']; $type = SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'];
} else {
continue;
} }
//Connection Error Creation
$connectionError = true;
$LastRecordTime = new DateTime($subDevicesData[$subDeviceKey][$key]['time']);
$interval = $LastRecordTime->diff(new DateTime());
$lastSeen = ($interval->format('%h') * 60 + $interval->format('%i'));
if ($subDevicesData[$subDeviceKey][$key]['sleep_time'] == NULL || $subDevicesData[$subDeviceKey][$key]['sleep_time'] == 0 || $lastSeen < $subDevicesData[$subDeviceKey][$key]['sleep_time']) {
$connectionError = false;
}
$subDevicesData[$subDeviceKey][$key]['connection_error'] = $connectionError;
//Record Translation
$cammelCaseClass = ""; $cammelCaseClass = "";
foreach (explode('-', $type) as $word) { foreach (explode('-', $type) as $word) {
$cammelCaseClass .= ucfirst($word); $cammelCaseClass .= ucfirst($word);
} }
if (!class_exists($cammelCaseClass)) { if (class_exists($cammelCaseClass)) {
continue;
}
$deviceClass = new $cammelCaseClass; $deviceClass = new $cammelCaseClass;
if (!method_exists($deviceClass, 'translate')) { if (method_exists($deviceClass, 'translate')) {
continue;
}
$subDevicesData[$subDeviceKey][$key]['value'] = $deviceClass->translate($subDevicesData[$subDeviceKey][$key]['value']); $subDevicesData[$subDeviceKey][$key]['value'] = $deviceClass->translate($subDevicesData[$subDeviceKey][$key]['value']);
} }
} }
}
}
foreach ($roomsData as $roomKey => $roomData) { foreach ($roomsData as $roomKey => $roomData) {
if ($roomData['device_count'] == 0) continue; if ($roomData['device_count'] == 0) continue;
$subDevicesSorted = isset($subDevicesData[$roomData['room_id']]) ? Utilities::sortArrayByKey($subDevicesData[$roomData['room_id']], 'connection_error', 'asc') : [];
$response[] = [ $response[] = [
'room_id' => $roomData['room_id'], 'room_id' => $roomData['room_id'],
'name' => $roomData['name'], 'name' => $roomData['name'],
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [], 'widgets' => $subDevicesSorted,
]; ];
} }
$this->response($response); $this->response($response);
} }

View File

@@ -44,10 +44,8 @@ class WidgetApi extends ApiController
]; ];
$response = null; $response = null;
$connectionError = true; $subDeviceData = SubDeviceManager::getSubdeviceDetailById($subDeviceId);
$subDeviceData = SubDeviceManager::getSubDevice($subDeviceId);
$deviceData = DeviceManager::getDeviceById($subDeviceData['device_id']);
//TODO: zeptat se @Patrik Je Graf Dobře Seřazený na DESC ? //TODO: zeptat se @Patrik Je Graf Dobře Seřazený na DESC ?
$events = RecordManager::getAllRecordForGraph($subDeviceId, $period, $groupBy[$period]); $events = RecordManager::getAllRecordForGraph($subDeviceId, $period, $groupBy[$period]);
@@ -65,20 +63,6 @@ class WidgetApi extends ApiController
$LastRecordTime = new DateTime(reset($events)['time']); $LastRecordTime = new DateTime(reset($events)['time']);
$niceTime = Utilities::ago($LastRecordTime); $niceTime = Utilities::ago($LastRecordTime);
$interval = $LastRecordTime->diff(new DateTime());
$hours = $interval->format('%h');
$minutes = $interval->format('%i');
$lastSeen = ($hours * 60 + $minutes);
if (
$lastSeen < $deviceData['sleep_time'] ||
$subDeviceData['type'] == "on/off" ||
$subDeviceData['type'] == "door" ||
$subDeviceData['type'] == "wather"
) {
$connectionError = false;
}
$labels = []; $labels = [];
$values = []; $values = [];
foreach ($events as $key => $event) { foreach ($events as $key => $event) {
@@ -95,6 +79,9 @@ class WidgetApi extends ApiController
} }
$response = [ $response = [
'room_id' => $subDeviceData['room_id'],
'device_id' => $subDeviceData['device_id'],
'lastConnectionTime' => (empty($niceTime) ? "00:00" : $niceTime),
'records' => $events, 'records' => $events,
'graph' => [ 'graph' => [
'type' => $this->getDeviceConfig($subDeviceData['type'])['graph'], 'type' => $this->getDeviceConfig($subDeviceData['type'])['graph'],
@@ -124,8 +111,7 @@ class WidgetApi extends ApiController
], ],
], ],
], ],
'comError' => $connectionError,
'lastConnectionTime' => (empty($niceTime) ? "00:00" : $niceTime),
]; ];
//TODO: Make Cleaner //TODO: Make Cleaner

View File

@@ -26,6 +26,10 @@ class GoogleHome {
} }
} }
if ($traids < 0){
continue;
}
$tempDevice = [ $tempDevice = [
'id' => (string) $deviceData['device_id'], 'id' => (string) $deviceData['device_id'],
'type' => $actionType, 'type' => $actionType,

View File

@@ -28,10 +28,6 @@ class RecordManager{
//Ochrana proti duplicitním hodnotám zapisují se jen změny //Ochrana proti duplicitním hodnotám zapisují se jen změny
$lastRecord = self::getLastRecord($subDeviceId, 1); $lastRecord = self::getLastRecord($subDeviceId, 1);
if (!$lastRecord){
return false;
}
if ($lastRecord['value'] == $value){ if ($lastRecord['value'] == $value){
return false; return false;
} }

View File

@@ -4,14 +4,20 @@ class SettingsManager{
return Db::loadAll ("SELECT * FROM settings"); return Db::loadAll ("SELECT * FROM settings");
} }
static function getByName($settingName) { static function getByName($settingName, $type = '') {
if ($type != '') return Db::loadOne("SELECT * FROM settings WHERE name = ? AND type = ?", array($settingName, $type));
return Db::loadOne("SELECT * FROM settings WHERE name = ?", array($settingName)); return Db::loadOne("SELECT * FROM settings WHERE name = ?", array($settingName));
} }
public static function create ($name, $value) { static function getSettingGroup($type) {
return Db::loadAll("SELECT * FROM settings WHERE type=?", array($type));
}
public static function create ($name, $value, $type = '') {
$setting = array ( $setting = array (
'name' => $name, 'name' => $name,
'value' => $value, 'value' => $value,
'type' => $type,
); );
try { try {
Db::add ('settings', $setting); Db::add ('settings', $setting);
@@ -21,13 +27,19 @@ class SettingsManager{
} }
} }
public static function update ($name, $value) { public static function update ($name, $value, $type = '') {
if (self::getByName($name)){
self::create($name, $value, $type);
} else {
try { try {
Db::edit ('settings', ['value' => $value], 'WHERE name = ?', array($name)); Db::edit ('settings', [
'value' => $value
], 'WHERE name = ?', array($name));
} catch(PDOException $error) { } catch(PDOException $error) {
echo $error->getMessage(); echo $error->getMessage();
die(); die();
} }
} }
}
} }
?> ?>

View File

@@ -5,7 +5,7 @@ class SubDeviceManager
public static function getAllSubDevices($deviceId = null) public static function getAllSubDevices($deviceId = null)
{ {
if ($deviceId == null){ if ($deviceId == null) {
return Db::loadAll("SELECT * FROM subdevices"); return Db::loadAll("SELECT * FROM subdevices");
} }
return Db::loadAll("SELECT * FROM subdevices WHERE device_id = ?", array($deviceId)); return Db::loadAll("SELECT * FROM subdevices WHERE device_id = ?", array($deviceId));
@@ -72,15 +72,16 @@ class SubDeviceManager
return Db::loadAll("DELETE FROM subdevices WHERE subdevice_id = ?", array($subDeviceId)); return Db::loadAll("DELETE FROM subdevices WHERE subdevice_id = ?", array($subDeviceId));
} }
public static function getSubdevicesByRoomIds($roomIds = NULL) { public static function getSubdevicesByRoomIds($roomIds = NULL)
if(empty($roomIds)) return NULL; {
if (empty($roomIds)) return NULL;
//TODO: @Patrik Check line 89 //TODO: @Patrik Check line 89
$rows = Db::loadAll(" $rows = Db::loadAll("
SELECT d.room_id, sd.subdevice_id, sd.device_id, d.icon, d.name, sd.type, sd.unit, r.value FROM subdevices sd SELECT d.room_id, d.sleep_time, sd.subdevice_id, sd.device_id, d.icon, d.name, sd.type, sd.unit, r.value, r.time FROM subdevices sd
JOIN devices d ON sd.device_id = d.device_id JOIN devices d ON sd.device_id = d.device_id
JOIN records r ON r.subdevice_id = sd.subdevice_id JOIN records r ON r.subdevice_id = sd.subdevice_id
WHERE d.room_id IN (".str_repeat("?,", count($roomIds)-1)."?) WHERE d.room_id IN (" . str_repeat("?,", count($roomIds) - 1) . "?)
/*AND value != '999'*/ /*AND value != '999'*/
AND r.record_id IN ( AND r.record_id IN (
SELECT MAX(record_id) SELECT MAX(record_id)
@@ -92,10 +93,21 @@ class SubDeviceManager
", $roomIds); ", $roomIds);
$ret = []; $ret = [];
foreach($rows as $row){ foreach ($rows as $row) {
$ret[$row['room_id']][] = $row; $ret[$row['room_id']][] = $row;
} }
return $ret; return $ret;
} }
public static function getSubdeviceDetailById($subDeviceId){
if (empty($subDeviceId)) return NULL;
$rows = Db::loadOne("SELECT d.room_id, d.sleep_time, sd.subdevice_id, sd.type, sd.device_id FROM subdevices sd
JOIN devices d ON sd.device_id = d.device_id
WHERE sd.subdevice_id = ? ", [$subDeviceId]);
return $rows;
}
} }

View File

@@ -53,6 +53,7 @@ class Automation extends Template
$template = new Template('automation'); $template = new Template('automation');
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('baseUrl', BASEURL);
$template->prepare('debugMod', DEBUGMOD); $template->prepare('debugMod', DEBUGMOD);
$template->prepare('title', 'Automation'); $template->prepare('title', 'Automation');
$template->prepare('langMng', $langMng); $template->prepare('langMng', $langMng);

View File

@@ -19,6 +19,7 @@ class Log extends Template
$result = $this->logFinder ('../logs/', $result); $result = $this->logFinder ('../logs/', $result);
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('baseUrl', BASEURL);
$template->prepare('debugMod', DEBUGMOD); $template->prepare('debugMod', DEBUGMOD);
$template->prepare('logToLiveTime', LOGTIMOUT); $template->prepare('logToLiveTime', LOGTIMOUT);
$template->prepare('title', 'Logy'); $template->prepare('title', 'Logy');

View File

@@ -12,6 +12,7 @@ class Login extends Template
$template = new Template('login'); $template = new Template('login');
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('baseUrl', BASEURL);
$template->prepare('title', 'Home'); $template->prepare('title', 'Home');

View File

@@ -8,6 +8,7 @@ class Oauth extends Template
$template = new Template('oauth'); $template = new Template('oauth');
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('baseUrl', BASEURL);
$template->prepare('title', 'Simple Home - Oauth'); $template->prepare('title', 'Simple Home - Oauth');
if (isset($_GET['redirect_uri'])) { if (isset($_GET['redirect_uri'])) {

View File

@@ -25,6 +25,7 @@ class Plugins extends Template
$template = new Template('plugins'); $template = new Template('plugins');
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('baseUrl', BASEURL);
$template->prepare('debugMod', DEBUGMOD); $template->prepare('debugMod', DEBUGMOD);
$template->prepare('title', 'Plugins'); $template->prepare('title', 'Plugins');
$template->prepare('langMng', $langMng); $template->prepare('langMng', $langMng);

View File

@@ -36,6 +36,7 @@ class Server extends Template
$template->prepare('title', 'Server'); $template->prepare('title', 'Server');
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('baseUrl', BASEURL);
$template->prepare('debugMod', DEBUGMOD); $template->prepare('debugMod', DEBUGMOD);
$template->prepare('langMng', $langMng); $template->prepare('langMng', $langMng);

View File

@@ -23,6 +23,7 @@ class Setting extends Template
$template = new Template('setting'); $template = new Template('setting');
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('baseUrl', BASEURL);
$template->prepare('debugMod', DEBUGMOD); $template->prepare('debugMod', DEBUGMOD);
$template->prepare('title', 'Automation'); $template->prepare('title', 'Automation');
$template->prepare('langMng', $langMng); $template->prepare('langMng', $langMng);
@@ -55,7 +56,27 @@ class Setting extends Template
$rooms = RoomManager::getAllRooms(); $rooms = RoomManager::getAllRooms();
$template->prepare('rooms', $rooms); $template->prepare('rooms', $rooms);
$settingsManager = new SettingsManager();
$dir = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/';
$pluginsFiles = array_diff (scandir ($dir), ['..', '.']);
$plugins = array ();
foreach ($pluginsFiles as $key => $pluginFile) {
$status = (strpos ($pluginFile, "!") !== false ? false : true);
if ($status) {
$plugins[$key]['name'] = str_replace ("!", "", str_replace (".php", "", $pluginFile));
$plugins[$key]['slug'] = strtolower ($plugins[$key]['name']);
$result = $settingsManager->getSettingGroup($plugins[$key]['slug']);
if (count ($result) > 0) {
$plugins[$key]['settings'] = $result;
}
}
}
$plugins = Utilities::sortArrayByKey($plugins, 'slug', "desc");
$template->prepare('pluginsSettings', $plugins);
$template->render(); $template->render();
} }

View File

@@ -4,6 +4,8 @@
<?php <?php
$partial = new Partial('head'); $partial = new Partial('head');
$partial->prepare('baseDir',$BASEDIR); $partial->prepare('baseDir',$BASEDIR);
$partial->prepare('baseUrl',$BASEURL);
$partial->render(); $partial->render();
?> ?>
<title><?php echo $TITLE ?></title> <title><?php echo $TITLE ?></title>

View File

@@ -4,6 +4,7 @@
<?php <?php
$partial = new Partial('head'); $partial = new Partial('head');
$partial->prepare('baseDir', $BASEDIR); $partial->prepare('baseDir', $BASEDIR);
$partial->prepare('baseUrl', $BASEURL);
$partial->render(); $partial->render();
?> ?>
<title><?php echo $TITLE ?></title> <title><?php echo $TITLE ?></title>

10
composer.json Normal file
View File

@@ -0,0 +1,10 @@
{
"autoload": {
"psr-4": {
"Core\\": "core/"
}
},
"require": {
"illuminate/container": "^8.18"
}
}

207
composer.lock generated Normal file
View File

@@ -0,0 +1,207 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c3305b3f3f6089062c2031140866dab7",
"packages": [
{
"name": "illuminate/container",
"version": "v8.18.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
"reference": "657cac2aa601aa0223afe0ed8627d0cb443f6a22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/container/zipball/657cac2aa601aa0223afe0ed8627d0cb443f6a22",
"reference": "657cac2aa601aa0223afe0ed8627d0cb443f6a22",
"shasum": ""
},
"require": {
"illuminate/contracts": "^8.0",
"php": "^7.3|^8.0",
"psr/container": "^1.0"
},
"provide": {
"psr/container-implementation": "1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "8.x-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Container\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Container package.",
"homepage": "https://laravel.com",
"time": "2020-12-01T14:31:29+00:00"
},
{
"name": "illuminate/contracts",
"version": "v8.18.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
"reference": "a73835aad399da42e88217bdbb5e1e4c1e668807"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/a73835aad399da42e88217bdbb5e1e4c1e668807",
"reference": "a73835aad399da42e88217bdbb5e1e4c1e668807",
"shasum": ""
},
"require": {
"php": "^7.3|^8.0",
"psr/container": "^1.0",
"psr/simple-cache": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "8.x-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Contracts\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Contracts package.",
"homepage": "https://laravel.com",
"time": "2020-11-18T13:57:08+00:00"
},
{
"name": "psr/container",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"time": "2017-02-14T16:28:37+00:00"
},
{
"name": "psr/simple-cache",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\SimpleCache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interfaces for simple caching",
"keywords": [
"cache",
"caching",
"psr",
"psr-16",
"simple-cache"
],
"time": "2017-10-23T01:57:42+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "1.1.0"
}

5
config/application.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
return [
'providers' => []
];

View File

@@ -0,0 +1,26 @@
<?php
namespace Core\Application;
use Core\Configuration\Configurations;
use Illuminate\Container\Container;
class Application
{
/** @var Container $container */
private $container;
/** @var Configurations */
private $configurations;
public function __construct(Container $container, Configurations $configurations)
{
$this->container = $container;
$this->configurations = $configurations;
}
public function run(): void
{
//todo: implement run logic.
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Core\Configuration;
class ConfigurationLoader
{
private const CONFIGURATIONS_DIRECTORY = __DIR__ . DIRECTORY_SEPARATOR
. '..' . DIRECTORY_SEPARATOR
. '..' . DIRECTORY_SEPARATOR . 'config'
. DIRECTORY_SEPARATOR;
public function load(): array
{
return [];
}
/**
* Concerns
* -> Loading configuration files
* - Scan directory for files.
* - Filtering none config / php files.
* - Creating assoc array.
*/
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Core\Configuration;
/**
* Class Configurations
* @package Core\Configuration
* @author Romano Schoonheim https://github.com/romano1996
*/
class Configurations
{
/** @var array */
private $configurations;
public function __construct(ConfigurationLoader $configurationLoader)
{
// Concern: Storing assoc array to this object.
$this->configurations = $configurationLoader->load();
}
public function get(string $path)
{
// Concern: Accessing configurations based on "paths" application.something For example.
}
}

View File

@@ -1,3 +1,33 @@
<?php <?php
/**
* Composer autoload
*/
use Core\Application\Application;
use Core\Configuration\Configurations;
use Illuminate\Container\Container;
require_once __DIR__ . '/../vendor/autoload.php';
$container = new Container();
$container->singleton(
Configurations::class,
Configurations::class
);
/**
* Create application & run
*/
$application = new Application(
$container,
$container->make(Configurations::class)
);
$application->run();
/**
* Bootstrap v1.0
*/
require_once __DIR__ . '/../app/Bootstrap.php'; require_once __DIR__ . '/../app/Bootstrap.php';