From cf30a1280de25c2d8c8b50109b1c333e40f21699 Mon Sep 17 00:00:00 2001 From: Romano Schoonheim Date: Tue, 15 Dec 2020 21:10:42 +0100 Subject: [PATCH 1/3] Really basic application object. --- composer.json | 11 +- composer.lock | 207 +++++++++++++++++++++++++++++++ core/Application/Application.php | 20 +++ public/index.php | 21 +++- 4 files changed, 255 insertions(+), 4 deletions(-) create mode 100644 composer.lock create mode 100644 core/Application/Application.php diff --git a/composer.json b/composer.json index 0967ef4..d189706 100644 --- a/composer.json +++ b/composer.json @@ -1 +1,10 @@ -{} +{ + "autoload": { + "psr-4": { + "Core\\": "core/" + } + }, + "require": { + "illuminate/container": "^8.18" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..15a7e98 --- /dev/null +++ b/composer.lock @@ -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" +} diff --git a/core/Application/Application.php b/core/Application/Application.php new file mode 100644 index 0000000..d140a8d --- /dev/null +++ b/core/Application/Application.php @@ -0,0 +1,20 @@ +container = $container; + } + + public function run() + { + //todo: implement run logic. + } +} diff --git a/public/index.php b/public/index.php index 42cbe35..f1260ab 100644 --- a/public/index.php +++ b/public/index.php @@ -3,9 +3,24 @@ /** * Composer autoload */ - require_once __DIR__ . '/../vendor/autoload.php'; + +use Core\Application\Application; +use Illuminate\Container\Container; + +require_once __DIR__ . '/../vendor/autoload.php'; + +$container = new Container(); /** - * todo: Create a new bootstrap architecture. + * Load providers */ -require_once __DIR__ . '/../app/Bootstrap.php'; + + + +/** + * Create application & run + */ +$application = new Application( + $container +); +$application->run(); -- 2.40.1 From bf79e9cee7e328bef280851df1109498705093fa Mon Sep 17 00:00:00 2001 From: Romano Schoonheim Date: Tue, 15 Dec 2020 21:46:46 +0100 Subject: [PATCH 2/3] Introduced configurations and application object (test code) --- config/application.php | 5 ++ core/Application/Application.php | 10 +++- core/Configuration/Configurations.php | 54 ++++++++++++++++++++ core/Configuration/Factories/FileFactory.php | 8 +++ core/Configuration/FileSystem.php | 33 ++++++++++++ core/Configuration/Objects/File.php | 10 ++++ public/index.php | 19 ++++--- 7 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 config/application.php create mode 100644 core/Configuration/Configurations.php create mode 100644 core/Configuration/Factories/FileFactory.php create mode 100644 core/Configuration/FileSystem.php create mode 100644 core/Configuration/Objects/File.php diff --git a/config/application.php b/config/application.php new file mode 100644 index 0000000..e4695b1 --- /dev/null +++ b/config/application.php @@ -0,0 +1,5 @@ + [] +]; diff --git a/core/Application/Application.php b/core/Application/Application.php index d140a8d..0dc6700 100644 --- a/core/Application/Application.php +++ b/core/Application/Application.php @@ -2,15 +2,21 @@ namespace Core\Application; +use Core\Configuration\Configurations; use Illuminate\Container\Container; class Application { - private Container $container; + /** @var Container $container */ + private $container; - public function __construct(Container $container) + /** @var Configurations */ + private $configurations; + + public function __construct(Container $container, Configurations $configurations) { $this->container = $container; + $this->configurations = $configurations; } public function run() diff --git a/core/Configuration/Configurations.php b/core/Configuration/Configurations.php new file mode 100644 index 0000000..7b4a093 --- /dev/null +++ b/core/Configuration/Configurations.php @@ -0,0 +1,54 @@ +getConfigurationFiles() as $configurationFile) { + print_r($configurationFile); + } + } + + + + +// private const IGNORED_FILES = [ +// '.', +// '..', +// 'config.php', +// 'config_sample.php' +// ]; +// +// +// private $configurations = []; +// +// public function __construct() +// { +// foreach (scandir(self::CONFIGURATION_DIRECTORY) as $item) { +// if (in_array($item, self::IGNORED_FILES)) { +// continue; +// } +// +// $filePath = self::CONFIGURATION_DIRECTORY . $item; +// +// +// +// +// die(); +// } +// } +// +// public function config(string $path): array +// { +// return $this->configurations; +// } +} diff --git a/core/Configuration/Factories/FileFactory.php b/core/Configuration/Factories/FileFactory.php new file mode 100644 index 0000000..1b126c4 --- /dev/null +++ b/core/Configuration/Factories/FileFactory.php @@ -0,0 +1,8 @@ +singleton( + Configurations::class, + Configurations::class +); /** * Create application & run */ $application = new Application( - $container + $container, + $container->make(Configurations::class) ); $application->run(); + + +/** + * Bootstrap v1.0 + */ +require_once __DIR__ . '/../app/Bootstrap.php'; -- 2.40.1 From f21293bc01650f09c32b3bce5a850f302ff0df43 Mon Sep 17 00:00:00 2001 From: Romano Schoonheim Date: Tue, 15 Dec 2020 21:50:42 +0100 Subject: [PATCH 3/3] Remove test code --- core/Application/Application.php | 2 +- core/Configuration/Configurations.php | 45 +------------------- core/Configuration/Factories/FileFactory.php | 8 ---- core/Configuration/FileSystem.php | 33 -------------- core/Configuration/Objects/File.php | 10 ----- 5 files changed, 2 insertions(+), 96 deletions(-) delete mode 100644 core/Configuration/Factories/FileFactory.php delete mode 100644 core/Configuration/FileSystem.php delete mode 100644 core/Configuration/Objects/File.php diff --git a/core/Application/Application.php b/core/Application/Application.php index 0dc6700..6ab0e31 100644 --- a/core/Application/Application.php +++ b/core/Application/Application.php @@ -19,7 +19,7 @@ class Application $this->configurations = $configurations; } - public function run() + public function run(): void { //todo: implement run logic. } diff --git a/core/Configuration/Configurations.php b/core/Configuration/Configurations.php index 7b4a093..8c4b9aa 100644 --- a/core/Configuration/Configurations.php +++ b/core/Configuration/Configurations.php @@ -8,47 +8,4 @@ namespace Core\Configuration; * @author Romano Schoonheim https://github.com/romano1996 */ class Configurations -{ - private $configurations = []; - - public function __construct(FileSystem $fileSystem) - { - foreach ($fileSystem->getConfigurationFiles() as $configurationFile) { - print_r($configurationFile); - } - } - - - - -// private const IGNORED_FILES = [ -// '.', -// '..', -// 'config.php', -// 'config_sample.php' -// ]; -// -// -// private $configurations = []; -// -// public function __construct() -// { -// foreach (scandir(self::CONFIGURATION_DIRECTORY) as $item) { -// if (in_array($item, self::IGNORED_FILES)) { -// continue; -// } -// -// $filePath = self::CONFIGURATION_DIRECTORY . $item; -// -// -// -// -// die(); -// } -// } -// -// public function config(string $path): array -// { -// return $this->configurations; -// } -} +{} diff --git a/core/Configuration/Factories/FileFactory.php b/core/Configuration/Factories/FileFactory.php deleted file mode 100644 index 1b126c4..0000000 --- a/core/Configuration/Factories/FileFactory.php +++ /dev/null @@ -1,8 +0,0 @@ -