Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ncou committed May 23, 2021
1 parent 00417f6 commit 82d8630
Show file tree
Hide file tree
Showing 26 changed files with 446 additions and 1,308 deletions.
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
"autoload-dev" : {
"psr-4": {
"Chiron\\Tests\\" : "tests/"
},
"files": [
"tests/Http/OverwritePhpFunctions.php"
]
}
},
"scripts": {
"test": [
Expand Down
7 changes: 0 additions & 7 deletions config/app.php.dist

This file was deleted.

6 changes: 6 additions & 0 deletions config/services.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'providers' => [],
'bootloaders' => []
];
10 changes: 10 additions & 0 deletions config/settings.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// TODO : ajouter un champ "environment" ??? qui contiendrait "developement" / "production" par exemple !!!!
return [
# SECURITY WARNING: don't run with debug turned on in production!
'debug' => env('APP_DEBUG', false),
'charset' => env('APP_ENCODING', 'UTF-8'),
'locale' => env('APP_DEFAULT_LOCALE', 'en_US'),
'timezone' => env('APP_DEFAULT_TIMEZONE', 'UTC'),
];
225 changes: 59 additions & 166 deletions src/Application.php

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions src/Bootloader/ApplicationBootloader.php

This file was deleted.

70 changes: 0 additions & 70 deletions src/Bootloader/CommandBootloader.php

This file was deleted.

27 changes: 0 additions & 27 deletions src/Bootloader/ConfigureBootloader.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Bootloader/ConsoleBootloader.php

This file was deleted.

18 changes: 0 additions & 18 deletions src/Bootloader/ConsoleDispatcherBootloader.php

This file was deleted.

15 changes: 8 additions & 7 deletions src/Bootloader/DirectoriesBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ public function __construct(array $paths)
/**
* @param Directories $directories
*/
public function boot(Directories $directories): void
public function boot(Directories $directories, Filesystem $filesystem): void
{
// Use default directories structure if needed.
$directories->init(self::mapDirectories($this->paths));
// insert the chiron framwork path for later use.
// Insert the chiron framwork path for later use.
$directories->set('framework', Framework::path());
// some folders should be presents and writables.

// Some folders should be presents and writables.
//self::assertWritableDir($directories, ['@runtime', '@cache']); // TODO : il faudrait plutot faire un Filesystem->ensureDirectoryExist(xxxx) pour forcer la création du répertoire si il n'existe pas !!!!

// TODO : eventuellement lever une exception si on n'arrive pas à créer ces répertoires !!! cad faire un try/catch autour de ces 2 appels !!!
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($directories->get('@runtime'));
$filesystem->ensureDirectoryExists($directories->get('@cache'));
}
Expand All @@ -61,19 +62,18 @@ private static function mapDirectories(array $paths): array

// TODO : il faudrait pas ajouter un répertoire pour les logs ???? => https://github.com/spiral/app/blob/85705bb7a0dafd010a83fa4bcc7323b019d8dda3/app/src/Bootloader/LoggingBootloader.php#L29
// TODO : faire le ménage on doit pas avoir besoin de tous ces répertoires !!! notamment le répertoire '@public' qui ne sert à rien lorsqu'on fait une application en ligne de commandes !!!!
// TODO : ajouter de maniére séparé le chemin ver vendor !!!
// TODO : ajouter de maniére séparé le chemin vers vendor !!!
$default = [
'@app' => '@root/app/',
'@config' => '@root/config/',
'@public' => '@root/public/',
'@resources' => '@root/resources/',
'@runtime' => '@root/runtime/',
'@vendor' => '@root/vendor/', // Assume a standard Composer directory structure unless specified
'@vendor' => '@root/vendor/', // Assume a standard Composer directory structure unless specified.
'@cache' => '@runtime/cache/',
];

// if a view engine is installed, we add the default 'views' folder.
// TODO : améliorer ce bout de code !!!!
if (interface_exists(TemplateRendererInterface::class)) {
$default['@views'] = '@resources/views/';
}
Expand All @@ -97,6 +97,7 @@ private static function normalizeAliases(array $paths): array
throw new DirectoryException('Directories paths aliases must be an associative array.');
}
// check if alias doesn't start with '@'
// TODO : utiliser la méthode Str::startWith(xxxx)
if (strncmp($alias, '@', 1) !== 0) {
$aliases['@' . $alias] = $path;
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/Bootloader/PackageManifestBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@

use Chiron\Application;
use Chiron\Core\Container\Bootloader\AbstractBootloader;
use Chiron\Container\FactoryInterface;
use Chiron\Composer\PackageManifest;
use Chiron\Service\ServiceManager;

//https://github.com/top-think/framework/blob/4de6f58c5e12a1ca80c788887b5208a6705f85d3/src/think/initializer/RegisterService.php

final class PackageManifestBootloader extends AbstractBootloader
{
/**
* Execute the providers & bootloaders classes found in the composer packages manifest.
* Add the services providers & bootloaders found in the composer packages manifest.
*
* @param PackageManifest $manifest
* @param Application $application
* @param FactoryInterface $factory
* @param ServiceManager $services
*/
// TODO : créer une fonction "factory()" dans le fichier function.php pour permettre d'initialiser les classes sans avoir à passer en paramétre un FactoryInterface !!!!
public function boot(PackageManifest $manifest, Application $application, FactoryInterface $factory): void
public function boot(PackageManifest $manifest, ServiceManager $services): void
{
foreach ($manifest->getProviders() as $provider) {
if (class_exists($provider)) {
$application->addProvider($factory->build($provider));
$services->addProvider($provider);
}
}

foreach ($manifest->getBootloaders() as $bootloader) {
if (class_exists($bootloader)) {
$application->addBootloader($factory->build($bootloader));
$services->addBootloader($bootloader);
}
}
}
Expand Down
19 changes: 0 additions & 19 deletions src/Bootloader/PublishAppBootloader.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/Bootloader/PublishConsoleBootloader.php

This file was deleted.

25 changes: 25 additions & 0 deletions src/Bootloader/ServicesBootloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Chiron\Bootloader;

use Chiron\Application;
use Chiron\Core\Container\Bootloader\AbstractBootloader;
use Chiron\Config\ServicesConfig;
use Chiron\Service\ServiceManager;

final class ServicesBootloader extends AbstractBootloader
{
// TODO : faire aussi un test class_exist avant de faire le addXXXX ? comme ce qu'on fait dans la classe PackageManifestBootloader ????
public function boot(ServiceManager $services, ServicesConfig $config): void
{
foreach ($config->getProviders() as $provider) {
$services->addProvider($provider);
}

foreach ($config->getBootloaders() as $bootloader) {
$services->addBootloader($bootloader);
}
}
}
1 change: 1 addition & 0 deletions src/Command/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//https://github.com/spiral/framework/blob/e865a013af9b75b712192c477b80066abb02ec0d/src/Framework/Command/PublishCommand.php
//https://github.com/spiral/framework/blob/e865a013af9b75b712192c477b80066abb02ec0d/src/Framework/Module/Publisher.php

// TODO : déplacer cette méthode dans le package chiron/core ????
// TODO : passer les méthodes "perform" en protected pour chaque classe de type "Command"
final class PublishCommand extends AbstractCommand
{
Expand Down
Loading

0 comments on commit 82d8630

Please sign in to comment.