diff --git a/aldarien/asset/.gitignore b/aldarien/asset/.gitignore
new file mode 100644
index 0000000..3b12249
--- /dev/null
+++ b/aldarien/asset/.gitignore
@@ -0,0 +1,11 @@
+composer.phar
+/vendor/
+
+# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
+# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
+# composer.lock
+
+#Eclipse IDE
+.settings
+.buildpath
+.project
diff --git a/aldarien/asset/LICENSE b/aldarien/asset/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/asset/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/asset/README.md b/aldarien/asset/README.md
new file mode 100644
index 0000000..1580798
--- /dev/null
+++ b/aldarien/asset/README.md
@@ -0,0 +1,2 @@
+# asset
+Asset manager module for my apps
diff --git a/aldarien/asset/app/Contract/Asset.php b/aldarien/asset/app/Contract/Asset.php
new file mode 100644
index 0000000..30b02c2
--- /dev/null
+++ b/aldarien/asset/app/Contract/Asset.php
@@ -0,0 +1,21 @@
+get($identifier);
+ }
+}
+?>
diff --git a/aldarien/asset/app/Helper/functions.php b/aldarien/asset/app/Helper/functions.php
new file mode 100644
index 0000000..b0688e2
--- /dev/null
+++ b/aldarien/asset/app/Helper/functions.php
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/aldarien/asset/app/Service/Asset.php b/aldarien/asset/app/Service/Asset.php
new file mode 100644
index 0000000..e7c36b7
--- /dev/null
+++ b/aldarien/asset/app/Service/Asset.php
@@ -0,0 +1,88 @@
+dir = config('locations.public');
+ }
+ public function get($identifier)
+ {
+ $asset = $this->find($identifier);
+ return $asset->url;
+ }
+ protected function find($identifier)
+ {
+ $type = $this->getType($identifier);
+ $asset = null;
+ if ($type == false) {
+ foreach (array_keys($this->assets) as $type) {
+ if (($asset = $this->getAsset($identifier, $type))) {
+ break;
+ }
+ }
+ } else {
+ $asset = $this->getAsset($identifier, $type);
+ }
+ return $asset;
+ }
+ protected function getType($identifier)
+ {
+ if (strpos($identifier, '.') !== false) {
+ list($name, $ext) = explode('.', $identifier);
+ return $ext;
+ }
+ return false;
+ }
+ protected function getAsset($identifier, $type)
+ {
+ if (!isset($this->assets[$type])) {
+ $this->loadAssets($type);
+ }
+ if (!isset($this->assets[$type])) {
+ return null;
+ }
+
+ foreach ($this->assets[$type] as $asset) {
+ if ($this->compareIdentifier($asset, $identifier)) {
+ return $asset;
+ }
+ }
+ return null;
+ }
+ protected function loadAssets($type)
+ {
+ $dir = $this->dir . '/' . $type . '/*.' . $type;
+ $files = glob($dir);
+ foreach ($files as $file) {
+ $url = $this->url($file);
+ $identifier = pathinfo($file)['filename'];
+
+ $this->assets[$type] []= (object) ['identifier' => $identifier, 'url' => $url, 'type' => $type];
+ }
+ }
+ protected function url($file)
+ {
+ $url = '/' . config('app.project') . '/' . str_replace('\\', '/', str_replace(realpath(config('locations.public')), '', dirname(realpath($file)))) . '/' . basename(realpath($file));
+ $url = preg_replace('/\/+/', '/', $url);
+ return $url;
+ }
+ protected function compareIdentifier($asset, $identifier)
+ {
+ if (strpos($identifier, '.') !== false) {
+ list($name, $ext) = explode('.', $identifier);
+ if ($asset->identifier == $name and $asset->type == $ext) {
+ return true;
+ }
+ } else {
+ if ($asset->identifier == $identifier) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/aldarien/asset/composer.json b/aldarien/asset/composer.json
new file mode 100644
index 0000000..6623a3e
--- /dev/null
+++ b/aldarien/asset/composer.json
@@ -0,0 +1,26 @@
+{
+ "name" : "aldarien/asset",
+ "description" : "Asset manager module for my apps",
+ "type" : "library",
+ "require" : {
+ "aldarien/config" : "dev-master",
+ "aldarien/contract" : "dev-master"
+ },
+ "require-dev" : {
+ "phpunit/phpunit" : "^6.3"
+ },
+ "license" : "MIT",
+ "authors" : [{
+ "name" : "Aldarien",
+ "email" : "aldarien85@gmail.com"
+ }
+ ],
+ "autoload" : {
+ "psr-4" : {
+ "App\\" : "app"
+ },
+ "files": [
+ "app/Helper/functions.php"
+ ]
+ }
+}
diff --git a/aldarien/asset/phpunit.xml b/aldarien/asset/phpunit.xml
new file mode 100644
index 0000000..e60ecbd
--- /dev/null
+++ b/aldarien/asset/phpunit.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ ./tests/
+
+
+
+
+ ./app
+
+
+
\ No newline at end of file
diff --git a/aldarien/asset/tests/AssetTest.php b/aldarien/asset/tests/AssetTest.php
new file mode 100644
index 0000000..e53f0ad
--- /dev/null
+++ b/aldarien/asset/tests/AssetTest.php
@@ -0,0 +1,25 @@
+assertEquals(asset('style.css'), '/css/style.css');
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/config/.gitignore b/aldarien/config/.gitignore
new file mode 100644
index 0000000..47c4114
--- /dev/null
+++ b/aldarien/config/.gitignore
@@ -0,0 +1,13 @@
+composer.phar
+/vendor/
+
+# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
+# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
+# composer.lock
+
+config
+
+# Eclipse IDE
+.settings
+.buildpath
+.project
\ No newline at end of file
diff --git a/aldarien/config/.travis.yml b/aldarien/config/.travis.yml
new file mode 100644
index 0000000..a792980
--- /dev/null
+++ b/aldarien/config/.travis.yml
@@ -0,0 +1,3 @@
+language: php
+php: '7.1'
+install: composer update
diff --git a/aldarien/config/LICENSE b/aldarien/config/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/config/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/config/README.md b/aldarien/config/README.md
new file mode 100644
index 0000000..dfed35b
--- /dev/null
+++ b/aldarien/config/README.md
@@ -0,0 +1,4 @@
+# config
+Config module that recovers configuration files
+
+[](https://travis-ci.org/Aldarien/config)
diff --git a/aldarien/config/app/Contract/Config.php b/aldarien/config/app/Contract/Config.php
new file mode 100644
index 0000000..9664aca
--- /dev/null
+++ b/aldarien/config/app/Contract/Config.php
@@ -0,0 +1,31 @@
+get($name);
+ }
+ public static function set($name, $value)
+ {
+ $instance = self::getInstance();
+ return $instance->set($name, $value);
+ }
+ public static function addFile($filename)
+ {
+ $instance = self::getInstance();
+ return $instance->loadFile($filename);
+ }
+}
+?>
diff --git a/aldarien/config/app/Contract/YamlWrapper.php b/aldarien/config/app/Contract/YamlWrapper.php
new file mode 100644
index 0000000..0ab60f6
--- /dev/null
+++ b/aldarien/config/app/Contract/YamlWrapper.php
@@ -0,0 +1,21 @@
+
\ No newline at end of file
diff --git a/aldarien/config/app/Helper/functions.php b/aldarien/config/app/Helper/functions.php
new file mode 100644
index 0000000..e073f18
--- /dev/null
+++ b/aldarien/config/app/Helper/functions.php
@@ -0,0 +1,9 @@
+
diff --git a/aldarien/config/app/Service/Config.php b/aldarien/config/app/Service/Config.php
new file mode 100644
index 0000000..5ee4959
--- /dev/null
+++ b/aldarien/config/app/Service/Config.php
@@ -0,0 +1,146 @@
+dir = $dir;
+ $this->load();
+ }
+ protected function load()
+ {
+ $files = glob($this->dir . '/*.{php,json,yml}', GLOB_BRACE);
+ foreach ($files as $file) {
+ $info = pathinfo($file);
+ $name = $info['filename'];
+
+ $d = $this->getData($file);
+ $data[$name] = $d;
+ $data = array_merge($data, $this->translateArray($d, $name));
+ foreach ($data as $key => $value) {
+ $this->add($key, $value);
+ }
+ }
+ }
+ public function loadFile(string $filename)
+ {
+ if (!file_exists(realpath($filename))) {
+ return false;
+ }
+ $info = pathinfo($filename);
+ $name = $info['filename'];
+ $d = $this->getData($filename);
+ $data[$name] = $d;
+ $data = array_merge($data, $this->translateArray($d, $name));
+ foreach ($data as $key => $value) {
+ $this->add($key, $value);
+ }
+ return true;
+ }
+ protected function getData($filename)
+ {
+ $info = pathinfo($filename);
+
+ switch ($info['extension']) {
+ case 'php':
+ return include_once $filename;
+ case 'json':
+ return json_decode(file_get_contents($filename), true);
+ case 'yml':
+ return YamlWrapper::load($filename);
+ default:
+ throw new \DomainException('Invalid file extension for ' . $filename);
+ }
+ }
+ protected function translateArray($array, $level)
+ {
+ $output = [];
+ foreach ($array as $k1 => $l1) {
+ $key = $level . '.' . $k1;
+ if (is_array($l1)) {
+ $output[$key] = $l1;
+ $output = array_merge($output, $this->translateArray($l1, $key));
+ } else {
+ $output[$key] = $l1;
+ }
+ }
+ return $output;
+ }
+ protected function add($field, $value)
+ {
+ if (isset($this->data[$field])) {
+ if ($this->data[$field] == $value) {
+ return;
+ }
+ if (is_array($this->data[$field])) {
+ $this->data[$field] = $this->merge($this->data[$field], $this->replace($value));
+ } else {
+ $this->data[$field] = $this->replace($value);
+ }
+ } else {
+ $this->data[$field] = $this->replace($value);
+ }
+ }
+ protected function merge($arr1, $arr2)
+ {
+ $output = $arr1;
+ foreach ($arr2 as $k => $value) {
+ if (isset($arr1[$k])) {
+ if ($arr1[$k] == $value) {
+ continue;
+ }
+ if (is_array($arr1[$k])) {
+ $output[$k] = $this->merge($arr1[$k], $value);
+ } else {
+ $output[$k] = array_merge([$arr1[$k]], $value);
+ }
+ } else {
+ $output[$k] = $value;
+ }
+ }
+ return $output;
+ }
+ protected function replace($value)
+ {
+ if (is_array($value)) {
+ foreach ($value as $k => $v) {
+ $value[$k] = $this->replace($v);
+ }
+ return $value;
+ }
+ if (strpos($value, '{') !== false) {
+ while(strpos($value, '{') !== false) {
+ $ini = strpos($value, '{') + 1;
+ $end = strpos($value, '}', $ini);
+ $rep = substr($value, $ini, $end - $ini);
+ $value = str_replace('{' . $rep . '}', $this->get($rep), $value);
+ }
+ }
+ return $value;
+ }
+
+ public function get($name = null)
+ {
+ if ($name == null) {
+ return $this->data;
+ }
+ if (isset($this->data[$name])) {
+ return $this->data[$name];
+ }
+ return null;
+ }
+ public function set($name, $value)
+ {
+ $this->add($name, $value);
+ }
+}
+?>
diff --git a/aldarien/config/bootstrap/autoload.php b/aldarien/config/bootstrap/autoload.php
new file mode 100644
index 0000000..42765bd
--- /dev/null
+++ b/aldarien/config/bootstrap/autoload.php
@@ -0,0 +1,3 @@
+
diff --git a/aldarien/config/composer.json b/aldarien/config/composer.json
new file mode 100644
index 0000000..8225292
--- /dev/null
+++ b/aldarien/config/composer.json
@@ -0,0 +1,28 @@
+{
+ "name": "aldarien/config",
+ "description": "Config module for my apps",
+ "type": "library",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Aldarien",
+ "email": "aldarien85@gmail.com"
+ }
+ ],
+ "require": {
+ "aldarien/contract": "dev-master",
+ "aldarien/root": "dev-master",
+ "symfony/yaml": "^3.3"
+ },
+ "autoload": {
+ "psr-4": {
+ "App\\": "app"
+ },
+ "files": [
+ "app/Helper/functions.php"
+ ]
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.3"
+ }
+}
diff --git a/aldarien/config/phpunit.xml b/aldarien/config/phpunit.xml
new file mode 100644
index 0000000..db312e1
--- /dev/null
+++ b/aldarien/config/phpunit.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ ./tests/
+
+
+
+
+ ./app
+
+
+
\ No newline at end of file
diff --git a/aldarien/config/tests/ConfigTest.php b/aldarien/config/tests/ConfigTest.php
new file mode 100644
index 0000000..187e0a3
--- /dev/null
+++ b/aldarien/config/tests/ConfigTest.php
@@ -0,0 +1,90 @@
+ 'Config', 'test_array' => ['data1' => 1, 'data2' => 2]]; ?>";
+ file_put_contents(dirname(__DIR__) . '/config/app.php', $str);
+ $data = ['name' => 'Config', 'test_array' => ['data1' => 1, 'data2' => 2]];
+ file_put_contents(dirname(__DIR__) . '/config/json.json', json_encode($data));
+ file_put_contents(dirname(__DIR__) . '/config/yaml.yml', YamlWrapper::dump($data));
+ $data = ['last_name' => 'Config'];
+ file_put_contents(dirname(__DIR__) . '/config/yaml.json', json_encode($data));
+ }
+ public function testGetNamePhp()
+ {
+ $name = 'Config';
+
+ $this->assertEquals($name, config('app.name'));
+ }
+ public function testGetNameJson()
+ {
+ $name = 'Config';
+
+ $this->assertEquals($name, config('json.name'));
+ }
+ public function testGetNameYaml()
+ {
+ $name = 'Config';
+
+ $this->assertEquals($name, config('yaml.name'));
+ }
+ public function testSetNamehp()
+ {
+ $new_name = 'Config_Test';
+ config('app.name', $new_name);
+ $this->assertEquals($new_name, config('app.name'));
+ }
+ public function testSetNameJson()
+ {
+ $new_name = 'Config_Test';
+ config('json.name', $new_name);
+ $this->assertEquals($new_name, config('json.name'));
+ }
+ public function testSetNameYaml()
+ {
+ $new_name = 'Config_Test';
+ config('yaml.name', $new_name);
+ $this->assertEquals($new_name, config('yaml.name'));
+ }
+ public function testArrayGetPhp()
+ {
+ $this->assertArrayHasKey('data1', config('app.test_array'));
+ }
+ public function testArrayGetJson()
+ {
+ $this->assertArrayHasKey('data1', config('json.test_array'));
+ }
+ public function testArrayGetYaml()
+ {
+ $this->assertArrayHasKey('data1', config('yaml.test_array'));
+ }
+ public function testSameSectionName()
+ {
+ $this->assertEquals('Config', config('yaml.last_name'));
+ }
+ public function testDuplicateValue()
+ {
+ config('json.name', 'Config2');
+ $this->assertEquals('Config2', config('json.name'));
+ }
+ public function testAddFile()
+ {
+ $filename = dirname(__DIR__) . '/composer.json';
+ App\Contract\Config::addFile($filename);
+ $this->assertEquals('aldarien/config', config('composer.name'));
+ }
+ public function tearDown()
+ {
+ unlink(dirname(__DIR__) . '/config/app.php');
+ unlink(dirname(__DIR__) . '/config/json.json');
+ unlink(dirname(__DIR__) . '/config/yaml.yml');
+ unlink(dirname(__DIR__) . '/config/yaml.json');
+ rmdir(dirname(__DIR__) . '/config');
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/contract/.gitignore b/aldarien/contract/.gitignore
new file mode 100644
index 0000000..c422267
--- /dev/null
+++ b/aldarien/contract/.gitignore
@@ -0,0 +1,6 @@
+composer.phar
+/vendor/
+
+# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
+# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
+# composer.lock
diff --git a/aldarien/contract/LICENSE b/aldarien/contract/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/contract/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/contract/app/Definition/Contract.php b/aldarien/contract/app/Definition/Contract.php
new file mode 100644
index 0000000..4cc88ca
--- /dev/null
+++ b/aldarien/contract/app/Definition/Contract.php
@@ -0,0 +1,20 @@
+
diff --git a/aldarien/contract/composer.json b/aldarien/contract/composer.json
new file mode 100644
index 0000000..96ef067
--- /dev/null
+++ b/aldarien/contract/composer.json
@@ -0,0 +1,18 @@
+{
+ "name": "aldarien/contract",
+ "description": "Contract trait for my apps",
+ "type": "library",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Aldarien",
+ "email": "aldarien85@gmail.com"
+ }
+ ],
+ "require": {},
+ "autoload": {
+ "psr-4": {
+ "App\\": "app"
+ }
+ }
+}
diff --git a/aldarien/format/.gitignore b/aldarien/format/.gitignore
new file mode 100644
index 0000000..6ee50e6
--- /dev/null
+++ b/aldarien/format/.gitignore
@@ -0,0 +1,11 @@
+composer.phar
+/vendor/
+
+# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
+# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
+# composer.lock
+
+# Eclipse IDE
+.settings
+.buildpath
+.project
\ No newline at end of file
diff --git a/aldarien/format/LICENSE b/aldarien/format/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/format/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/format/README.md b/aldarien/format/README.md
new file mode 100644
index 0000000..d4f839f
--- /dev/null
+++ b/aldarien/format/README.md
@@ -0,0 +1,2 @@
+# format
+Module for formatting data, mostly numbers
diff --git a/aldarien/format/app/Helper/Format.php b/aldarien/format/app/Helper/Format.php
new file mode 100644
index 0000000..9836f38
--- /dev/null
+++ b/aldarien/format/app/Helper/Format.php
@@ -0,0 +1,43 @@
+format("d \d\\e F Y");
+ }
+ public static function shortDate(string $date)
+ {
+ $d = \Carbon\Carbon::parse($date, config('app.timezone'));
+ return $d->format('d-m-Y');
+ }
+ public static function localDate(string $date)
+ {
+ $d = \Carbon\Carbon::parse($date, config('app.timezone'));
+ setlocale(LC_TIME, 'es');
+ return $d->formatLocalized('%d de %B de %Y');
+ }
+ public static function m2(float $number, bool $print = false)
+ {
+ return self::number($number, 2) . (($print) ? ' m²' : '');
+ }
+ public static function percent(float $number, bool $print = false)
+ {
+ return self::number($number, 2) . (($print) ? '%' : '');
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/format/composer.json b/aldarien/format/composer.json
new file mode 100644
index 0000000..80c49ca
--- /dev/null
+++ b/aldarien/format/composer.json
@@ -0,0 +1,23 @@
+{
+ "name" : "aldarien/format",
+ "description" : "Module for formatting data, mostly numbers",
+ "type" : "library",
+ "require-dev" : {
+ "phpunit/phpunit" : "^6",
+ "aldarien/config": "dev-master"
+ },
+ "license" : "MIT",
+ "authors" : [{
+ "name" : "Aldarien",
+ "email" : "aldarien85@gmail.com"
+ }
+ ],
+ "autoload" : {
+ "psr-4" : {
+ "App\\" : "app"
+ }
+ },
+ "require": {
+ "nesbot/carbon": "^2"
+ }
+}
diff --git a/aldarien/format/config/app.php b/aldarien/format/config/app.php
new file mode 100644
index 0000000..9e747f9
--- /dev/null
+++ b/aldarien/format/config/app.php
@@ -0,0 +1,5 @@
+ 'America/Santiago'
+];
+?>
\ No newline at end of file
diff --git a/aldarien/format/phpunit.xml b/aldarien/format/phpunit.xml
new file mode 100644
index 0000000..e60ecbd
--- /dev/null
+++ b/aldarien/format/phpunit.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ ./tests/
+
+
+
+
+ ./app
+
+
+
\ No newline at end of file
diff --git a/aldarien/format/tests/FormatTest.php b/aldarien/format/tests/FormatTest.php
new file mode 100644
index 0000000..bcc6bd5
--- /dev/null
+++ b/aldarien/format/tests/FormatTest.php
@@ -0,0 +1,59 @@
+number, 3);
+ $this->assertEquals($output, $result);
+ }
+ public function testPesosPrint()
+ {
+ $output = '$ 5.049.872';
+ $result = Format::pesos($this->number, true);
+ $this->assertEquals($output, $result);
+ }
+ public function testUFPrint()
+ {
+ $output = '5.049.872,32 UF';
+ $result = Format::ufs($this->number, true);
+ $this->assertEquals($output, $result);
+ }
+ public function testDate()
+ {
+ $output = '25 de March 2016';
+ $result = Format::date($this->date);
+ $this->assertEquals($output, $result);
+ }
+ public function testShortDate()
+ {
+ $output = '25-03-2016';
+ $result = Format::shortDate($this->date);
+ $this->assertEquals($output, $result);
+ }
+ public function testLocalDate()
+ {
+ $output = '25 de marzo de 2016';
+ $result = Format::localDate($this->date);
+ $this->assertEquals($output, $result);
+ }
+ public function testM2Print()
+ {
+ $output = '5.049.872,32 m²';
+ $result = Format::m2($this->number, true);
+ $this->assertEquals($output, $result);
+ }
+ public function testPercentPrint()
+ {
+ $output = '5.049.872,32%';
+ $result = Format::percent($this->number, true);
+ $this->assertEquals($output, $result);
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/response/.gitignore b/aldarien/response/.gitignore
new file mode 100644
index 0000000..265bf84
--- /dev/null
+++ b/aldarien/response/.gitignore
@@ -0,0 +1,7 @@
+#Eclipse IDE
+.settings
+.buildpath
+.project
+
+#Composer
+vendor
diff --git a/aldarien/response/LICENSE b/aldarien/response/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/response/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/response/README.md b/aldarien/response/README.md
new file mode 100644
index 0000000..80c6096
--- /dev/null
+++ b/aldarien/response/README.md
@@ -0,0 +1,2 @@
+# response
+Response handler module for my apps
diff --git a/aldarien/response/app/Contract/Response.php b/aldarien/response/app/Contract/Response.php
new file mode 100644
index 0000000..4b0089e
--- /dev/null
+++ b/aldarien/response/app/Contract/Response.php
@@ -0,0 +1,27 @@
+
\ No newline at end of file
diff --git a/aldarien/response/app/Helper/functions.php b/aldarien/response/app/Helper/functions.php
new file mode 100644
index 0000000..32c48f8
--- /dev/null
+++ b/aldarien/response/app/Helper/functions.php
@@ -0,0 +1,11 @@
+
\ No newline at end of file
diff --git a/aldarien/response/app/Service/Response.php b/aldarien/response/app/Service/Response.php
new file mode 100644
index 0000000..290f9d5
--- /dev/null
+++ b/aldarien/response/app/Service/Response.php
@@ -0,0 +1,62 @@
+gump = new \GUMP();
+ }
+ public function sanitize()
+ {
+ if ($_POST) {
+ $this->post = $this->correctNumbers($this->gump->sanitize($_POST));
+ }
+ if ($_GET) {
+ $this->get = $this->correctNumbers($this->gump->sanitize($_GET));
+ }
+ }
+ public function correctNumbers(array $data)
+ {
+ $output = [];
+ foreach ($data as $key => $value) {
+ if (is_float(str_replace(',', '.', $value))) {
+ $output[$key] = str_replace(',', '.', $value);
+ } else {
+ $output[$key] = $value;
+ }
+ }
+ return $output;
+ }
+ public function get($query = null)
+ {
+ if ($this->get == null) {
+ $this->sanitize();
+ }
+ if ($query == null) {
+ return $this->get;
+ }
+ if (isset($this->get[$query])) {
+ return $this->get[$query];
+ }
+ return false;
+ }
+ public function post($query = null)
+ {
+ if ($this->post == null) {
+ $this->sanitize();
+ }
+ if ($query == null) {
+ return $this->post;
+ }
+ if (isset($this->post[$query])) {
+ return $this->post[$query];
+ }
+ return false;
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/response/bootstrap/autoload.php b/aldarien/response/bootstrap/autoload.php
new file mode 100644
index 0000000..b5e8220
--- /dev/null
+++ b/aldarien/response/bootstrap/autoload.php
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/aldarien/response/composer.json b/aldarien/response/composer.json
new file mode 100644
index 0000000..24744a8
--- /dev/null
+++ b/aldarien/response/composer.json
@@ -0,0 +1,26 @@
+{
+ "name" : "aldarien/response",
+ "description" : "Response handler module for my apps",
+ "type" : "library",
+ "require" : {
+ "wixel/gump" : "^1.5",
+ "aldarien/contract" : "dev-master"
+ },
+ "require-dev" : {
+ "phpunit/phpunit" : "^6.3"
+ },
+ "license" : "MIT",
+ "authors" : [{
+ "name" : "Aldarien",
+ "email" : "jpvial@gmail.com"
+ }
+ ],
+ "autoload" : {
+ "psr-4" : {
+ "App\\" : "app"
+ },
+ "files": [
+ "app/Helper/functions.php"
+ ]
+ }
+}
diff --git a/aldarien/response/phpunit.xml b/aldarien/response/phpunit.xml
new file mode 100644
index 0000000..db312e1
--- /dev/null
+++ b/aldarien/response/phpunit.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ ./tests/
+
+
+
+
+ ./app
+
+
+
\ No newline at end of file
diff --git a/aldarien/response/tests/ResponseTest.php b/aldarien/response/tests/ResponseTest.php
new file mode 100644
index 0000000..67d603c
--- /dev/null
+++ b/aldarien/response/tests/ResponseTest.php
@@ -0,0 +1,22 @@
+value;
+ $_POST['test'] = $this->value;
+ }
+ public function testGet()
+ {
+ $this->assertEquals($this->value, get('test'));
+ }
+ public function testPost()
+ {
+ $this->assertEquals($this->value, post('test'));
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/root/.gitignore b/aldarien/root/.gitignore
new file mode 100644
index 0000000..f7e7961
--- /dev/null
+++ b/aldarien/root/.gitignore
@@ -0,0 +1,5 @@
+.buildpath
+.project
+.settings
+*.lock
+vendor
\ No newline at end of file
diff --git a/aldarien/root/LICENSE b/aldarien/root/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/root/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/root/README.md b/aldarien/root/README.md
new file mode 100644
index 0000000..039cbc3
--- /dev/null
+++ b/aldarien/root/README.md
@@ -0,0 +1,22 @@
+# root
+get root directory path for your project
+
+## Usage
+
+add `Root::root('project')` or `root('project')` or `Root::root()` or `root()` where you need the root directory of your proyect.
+
+## Example
+
+For the structure:
+
+~~~
+/usr/share/www/projects
+- myProject
+-- src
+-- tests
+~~~
+
+using `Root::root('myProject')`
+
+outputs:
+`/usr/share/www/projects/myProject`
diff --git a/aldarien/root/app/Helper/functions.php b/aldarien/root/app/Helper/functions.php
new file mode 100644
index 0000000..86fd2eb
--- /dev/null
+++ b/aldarien/root/app/Helper/functions.php
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/aldarien/root/composer.json b/aldarien/root/composer.json
new file mode 100644
index 0000000..3898988
--- /dev/null
+++ b/aldarien/root/composer.json
@@ -0,0 +1,21 @@
+{
+ "name" : "aldarien/root",
+ "description" : "Find the root path for your proyect",
+ "authors" : [{
+ "name" : "Aldarien"
+ }
+ ],
+ "license": "MIT",
+ "require-dev" : {
+ "phpunit/phpunit" : "~6",
+ "kint-php/kint" : "~2"
+ },
+ "autoload" : {
+ "psr-4" : {
+ "Proyect\\Root\\" : "src"
+ },
+ "files": [
+ "app/Helper/functions.php"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/aldarien/root/phpunit.xml b/aldarien/root/phpunit.xml
new file mode 100644
index 0000000..63ecd1c
--- /dev/null
+++ b/aldarien/root/phpunit.xml
@@ -0,0 +1,19 @@
+
+
+
+ tests
+
+
+
+
+ src
+
+
+
diff --git a/aldarien/root/src/Root.php b/aldarien/root/src/Root.php
new file mode 100644
index 0000000..13058df
--- /dev/null
+++ b/aldarien/root/src/Root.php
@@ -0,0 +1,48 @@
+$proyect_name/public/index.php calls for $proyect_name/bootstrap/autoload.php
,
+ * you just need to
+ *
+ * include root() . '/bootstrap/autoload.php'
+ *
+ * @param string $proyect_name
+ * @return string
+ */
+ public static function root(string $proyect_name = '')
+ {
+ $dir = realpath(__DIR__);
+ if ($proyect_name == '') {
+ return self::findComposerFile($dir);
+ } else {
+ $ini = strpos($dir, $proyect_name) + strlen($proyect_name);
+ }
+ $path = substr($dir, $ini);
+ $cnt = substr_count($path, DIRECTORY_SEPARATOR);
+ $root = DIRECTORY_SEPARATOR;
+ for ($i = 0; $i < $cnt; $i ++) {
+ $root .= '..' . DIRECTORY_SEPARATOR;
+ }
+
+ return realpath($dir . $root);
+ }
+ protected static function findComposerFile($dir)
+ {
+ if (file_exists($dir . '/vendor/')) {
+ return $dir;
+ }
+
+ $root = realpath('/');
+ if (realpath($dir) == $root) {
+ return null;
+ }
+
+ $dir = dirname($dir);
+ return self::findComposerFile($dir);
+ }
+}
+?>
diff --git a/aldarien/root/tests/RootTest.php b/aldarien/root/tests/RootTest.php
new file mode 100644
index 0000000..1deed6c
--- /dev/null
+++ b/aldarien/root/tests/RootTest.php
@@ -0,0 +1,61 @@
+getCurrentDir();
+ $this->assertEquals($this->getRoot(), $this->current_dir);
+ $this->assertEquals($this->getBaseRoot(), $this->current_dir);
+ }
+ public function testBaseRootFunction()
+ {
+ $this->getCurrentDir();
+ $this->assertEquals($this->getFRoot(), $this->current_dir);
+ $this->assertEquals($this->getFBaseRoot(), $this->current_dir);
+ }
+ public function testSrcRoot()
+ {
+ $this->changeDir('src');
+ $this->assertEquals(realpath($this->getRoot() . '/src'), $this->current_dir);
+ $this->assertEquals(realpath($this->getBaseRoot() . '/src'), $this->current_dir);
+ }
+ public function testSrcRootFunction()
+ {
+ $this->changeDir('src');
+ $this->assertEquals(realpath($this->getFRoot() . '/src'), $this->current_dir);
+ $this->assertEquals(realpath($this->getFBaseRoot() . '/src'), $this->current_dir);
+ }
+
+ private function getCurrentDir()
+ {
+ $this->current_dir = getcwd();
+ }
+ private function changeDir($dir)
+ {
+ chdir($dir);
+ $this->getCurrentDir();
+ }
+ private function getRoot()
+ {
+ return Root::root($this->proyect_name);
+ }
+ private function getBaseRoot()
+ {
+ return Root::root();
+ }
+ private function getFRoot()
+ {
+ return root($this->proyect_name);
+ }
+ private function getFBaseRoot()
+ {
+ return root();
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/session/.gitignore b/aldarien/session/.gitignore
new file mode 100644
index 0000000..6ee50e6
--- /dev/null
+++ b/aldarien/session/.gitignore
@@ -0,0 +1,11 @@
+composer.phar
+/vendor/
+
+# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
+# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
+# composer.lock
+
+# Eclipse IDE
+.settings
+.buildpath
+.project
\ No newline at end of file
diff --git a/aldarien/session/LICENSE b/aldarien/session/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/session/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/session/README.md b/aldarien/session/README.md
new file mode 100644
index 0000000..6825213
--- /dev/null
+++ b/aldarien/session/README.md
@@ -0,0 +1,2 @@
+# session
+Session wrapper for aura/session
diff --git a/aldarien/session/app/Contract/Session.php b/aldarien/session/app/Contract/Session.php
new file mode 100644
index 0000000..2968a8f
--- /dev/null
+++ b/aldarien/session/app/Contract/Session.php
@@ -0,0 +1,29 @@
+newInstance($_COOKIE);
+ }
+ public static function get($segment, $name)
+ {
+ $instance = self::getInstance();
+ $segment = $instance->getSegment($segment);
+ return $segment->get($name);
+ }
+ public static function set($segment, $name, $value)
+ {
+ $instance = self::getInstance();
+ $segment = $instance->getSegment($segment);
+ $segment->set($name, $value);
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/session/composer.json b/aldarien/session/composer.json
new file mode 100644
index 0000000..9a043b1
--- /dev/null
+++ b/aldarien/session/composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "aldarien/session",
+ "description": "Session wrapper for aura/session",
+ "type": "library",
+ "require": {
+ "aura/session": "^2.1",
+ "aldarien/contract": "dev-master"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.3"
+ },
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Aldarien",
+ "email": "aldarien85@gmail.com"
+ }
+ ],
+ "autoload": {
+ "psr-4": {
+ "App\\": "app"
+ }
+ }
+}
diff --git a/aldarien/url/.gitignore b/aldarien/url/.gitignore
new file mode 100644
index 0000000..a06a2f1
--- /dev/null
+++ b/aldarien/url/.gitignore
@@ -0,0 +1,12 @@
+composer.phar
+/vendor/
+
+# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
+# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
+# composer.lock
+
+.settings
+.buildpath
+.project
+
+# Eclipse IDE
\ No newline at end of file
diff --git a/aldarien/url/LICENSE b/aldarien/url/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/url/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/url/README.md b/aldarien/url/README.md
new file mode 100644
index 0000000..0c1a426
--- /dev/null
+++ b/aldarien/url/README.md
@@ -0,0 +1,2 @@
+# url
+Get relative path url
diff --git a/aldarien/url/app/Contract/URL.php b/aldarien/url/app/Contract/URL.php
new file mode 100644
index 0000000..14d7ef0
--- /dev/null
+++ b/aldarien/url/app/Contract/URL.php
@@ -0,0 +1,21 @@
+url($path, $variables);
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/url/app/Helper/functions.php b/aldarien/url/app/Helper/functions.php
new file mode 100644
index 0000000..6e9435e
--- /dev/null
+++ b/aldarien/url/app/Helper/functions.php
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/aldarien/url/app/Service/URL.php b/aldarien/url/app/Service/URL.php
new file mode 100644
index 0000000..e504acd
--- /dev/null
+++ b/aldarien/url/app/Service/URL.php
@@ -0,0 +1,76 @@
+root = $this->findRoot();
+ $this->relative = $this->findRelative();
+ }
+
+ protected function findRoot()
+ {
+ $base = $_SERVER['HTTP_HOST'] . ((isset($_SERVER['HTTP_PORT'])) ? ':' . $_SERVER['HTTP_PORT'] : '');
+ $uri = Http::createFromString(\Sabre\Uri\resolve($_SERVER['REQUEST_SCHEME'] . '://' . $base, $_SERVER['SCRIPT_NAME']));
+ $host = new Host($uri->getHost());
+ if ($host->isAbsolute()) {
+ return $host->getRegistrableDomain();
+ }
+ $base = $host . (($uri->getPort()) ? ':' . $uri->getPort() : '');
+ return ($uri->getScheme() ?: 'http') . '://' . $base;
+ }
+ protected function findRelative()
+ {
+ $uri = Http::createFromString($_SERVER['SCRIPT_NAME']);
+ $normalized = (new HierarchicalPath($uri->getPath()))->withoutLeadingSlash()->withoutTrailingSlash()->withoutDotSegments()->withoutEmptySegments();
+ if ($normalized->getDirname() == '.') {
+ return '';
+ }
+ return $normalized->getDirname();
+ }
+
+
+ public function url($path = '', $variables = null)
+ {
+ $uri = Http::createFromString($path);
+ if ($uri->getHost() != $this->root and $uri->getHost() != '') {
+ return $path;
+ }
+
+ $uri = \Sabre\Uri\resolve($this->getBaseUrl(), $path);
+ try {
+ $host = new Host(Http::createFromString($uri)->getHost());
+ } catch (\League\Uri\Exception $e) {
+ $uri = \Sabre\Uri\resolve($this->getBaseUrl(), '../../') . '/' . basename($path);
+ $host = new Host(Http::createFromString($uri)->getHost());
+ }
+
+ $base = new Host(Http::createFromString($this->root)->getHost());
+ if ($host . '' != $base . '') {
+ $host = new Host(Http::createFromString($this->root)->getHost());
+ $page = str_replace($this->root, '', $uri);
+ $uri = \Sabre\Uri\resolve(Http::createFromString($this->root)->getScheme() . '://' . $host->getRegistrableDomain(). '/', $page);
+ }
+
+ if ($variables != null) {
+ $uri = \Sabre\Uri\resolve($uri, '?' . http_build_query($variables));
+ }
+ $uri = \Sabre\Uri\normalize($uri);
+
+ return $uri;
+ }
+ protected function getBaseUrl()
+ {
+ $url = \Sabre\Uri\normalize(trim($this->root . '/' . $this->relative, '/') . '/');
+ return $url;
+ }
+}
+?>
\ No newline at end of file
diff --git a/aldarien/url/composer.json b/aldarien/url/composer.json
new file mode 100644
index 0000000..540d0ed
--- /dev/null
+++ b/aldarien/url/composer.json
@@ -0,0 +1,28 @@
+{
+ "name" : "aldarien/url",
+ "description" : "Get relative path uri",
+ "type" : "library",
+ "require" : {
+ "aldarien/contract" : "dev-master",
+ "aldarien/root" : "dev-master",
+ "league/uri": "^5.2",
+ "sabre/uri": "^2.1"
+ },
+ "require-dev" : {
+ "phpunit/phpunit" : "^6.3"
+ },
+ "license" : "MIT",
+ "authors" : [{
+ "name" : "Aldarien",
+ "email" : "jpvial@gmail.com"
+ }
+ ],
+ "autoload" : {
+ "psr-4" : {
+ "App\\" : "app"
+ },
+ "files": [
+ "app/Helper/functions.php"
+ ]
+ }
+}
diff --git a/aldarien/view/.gitignore b/aldarien/view/.gitignore
new file mode 100644
index 0000000..120b68f
--- /dev/null
+++ b/aldarien/view/.gitignore
@@ -0,0 +1,10 @@
+composer.phar
+/vendor/
+
+# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
+# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
+# composer.lock
+
+.settings
+.buildpath
+.project
diff --git a/aldarien/view/LICENSE b/aldarien/view/LICENSE
new file mode 100644
index 0000000..55dc05a
--- /dev/null
+++ b/aldarien/view/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Aldarien
+
+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.
diff --git a/aldarien/view/README.md b/aldarien/view/README.md
new file mode 100644
index 0000000..b888dbd
--- /dev/null
+++ b/aldarien/view/README.md
@@ -0,0 +1,2 @@
+# view
+View module for my apps
diff --git a/aldarien/view/app/Contract/View.php b/aldarien/view/app/Contract/View.php
new file mode 100644
index 0000000..bf0d289
--- /dev/null
+++ b/aldarien/view/app/Contract/View.php
@@ -0,0 +1,21 @@
+show($template, $variables);
+ }
+}
+?>
diff --git a/aldarien/view/app/Helper/functions.php b/aldarien/view/app/Helper/functions.php
new file mode 100644
index 0000000..ba0e9e1
--- /dev/null
+++ b/aldarien/view/app/Helper/functions.php
@@ -0,0 +1,5 @@
+
diff --git a/aldarien/view/app/Service/View.php b/aldarien/view/app/Service/View.php
new file mode 100644
index 0000000..dcdcbb0
--- /dev/null
+++ b/aldarien/view/app/Service/View.php
@@ -0,0 +1,27 @@
+views = config('locations.views');
+ $this->cache = config('locations.cache');
+
+ $this->blade = new Blade($this->views, $this->cache);
+ }
+ public function show($template, $vars = null)
+ {
+ if ($vars) {
+ return $this->blade->view()->make($template, $vars)->render();
+ }
+ return $this->blade->view()->make($template)->render();
+ }
+}
+?>
diff --git a/aldarien/view/cache/26fae499b6e99106ff3bd673b8eb7319ae68e7ae.php b/aldarien/view/cache/26fae499b6e99106ff3bd673b8eb7319ae68e7ae.php
new file mode 100644
index 0000000..8cafca1
--- /dev/null
+++ b/aldarien/view/cache/26fae499b6e99106ff3bd673b8eb7319ae68e7ae.php
@@ -0,0 +1,9 @@
+
+
+
+ View
+
+
+View test
+
+
\ No newline at end of file
diff --git a/aldarien/view/composer.json b/aldarien/view/composer.json
new file mode 100644
index 0000000..a18b995
--- /dev/null
+++ b/aldarien/view/composer.json
@@ -0,0 +1,28 @@
+{
+ "name": "aldarien/view",
+ "description": "View module for my apps",
+ "type": "library",
+ "require": {
+ "philo/laravel-blade": "^3.1",
+ "aldarien/contract": "dev-master",
+ "aldarien/config": "dev-master"
+ },
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Aldarien",
+ "email": "aldarien85@gmail.com"
+ }
+ ],
+ "autoload": {
+ "psr-4": {
+ "App\\": "app"
+ },
+ "files": [
+ "app/Helper/functions.php"
+ ]
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.3"
+ }
+}
diff --git a/aldarien/view/config/locations.php b/aldarien/view/config/locations.php
new file mode 100644
index 0000000..1dd0425
--- /dev/null
+++ b/aldarien/view/config/locations.php
@@ -0,0 +1,8 @@
+ root(),
+ 'cache' => '{locations.base}/cache',
+ 'resources' => '{locations.base}/resources',
+ 'views' => '{locations.resources}/views'
+];
+?>
\ No newline at end of file
diff --git a/aldarien/view/phpunit.xml b/aldarien/view/phpunit.xml
new file mode 100644
index 0000000..e60ecbd
--- /dev/null
+++ b/aldarien/view/phpunit.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ ./tests/
+
+
+
+
+ ./app
+
+
+
\ No newline at end of file
diff --git a/aldarien/view/public/index.php b/aldarien/view/public/index.php
new file mode 100644
index 0000000..1070f11
--- /dev/null
+++ b/aldarien/view/public/index.php
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/aldarien/view/resources/views/base.blade.php b/aldarien/view/resources/views/base.blade.php
new file mode 100644
index 0000000..8cafca1
--- /dev/null
+++ b/aldarien/view/resources/views/base.blade.php
@@ -0,0 +1,9 @@
+
+
+
+ View
+
+
+View test
+
+
\ No newline at end of file
diff --git a/aldarien/view/tests/ViewTest.php b/aldarien/view/tests/ViewTest.php
new file mode 100644
index 0000000..85f4aa6
--- /dev/null
+++ b/aldarien/view/tests/ViewTest.php
@@ -0,0 +1,22 @@
+
+
+
+ View
+
+
+View test
+
+
+DATA;
+ $this->assertEquals($output, view('base'));
+ }
+}
+?>
\ No newline at end of file