diff --git a/dev/App/Example.php b/dev/App/Example.php
index 4ef4c6b90..d3611d2d5 100644
--- a/dev/App/Example.php
+++ b/dev/App/Example.php
@@ -3,7 +3,10 @@
namespace LastDragon_ru\LaraASP\Dev\App;
use Illuminate\Console\Command;
+use Illuminate\Container\Container;
+use Illuminate\Contracts\Config\Repository;
use LastDragon_ru\LaraASP\Core\Utils\Cast;
+use LastDragon_ru\LaraASP\Core\Utils\ConfigMerger;
use LogicException;
use PhpParser\ErrorHandler\Collecting;
use PhpParser\Node;
@@ -18,6 +21,7 @@
use function array_map;
use function array_slice;
+use function config;
use function debug_backtrace;
use function end;
use function file;
@@ -58,8 +62,12 @@ protected static function getDumper(): Dumper {
}
public function __invoke(Dumper $dumper): void {
- $file = Cast::toString($this->argument('file'));
self::$dumper = $dumper;
+ $container = Container::getInstance();
+ $config = $container->make(Repository::class);
+ $file = Cast::toString($this->argument('file'));
+
+ $container[Repository::class] = clone $config;
try {
// Run
@@ -75,7 +83,10 @@ public function __invoke(Dumper $dumper): void {
$this->output->writeln("{$output}");
}
} finally {
- self::$dumper = null;
+ Container::setInstance($container);
+
+ $container[Repository::class] = $config;
+ self::$dumper = null;
}
}
@@ -87,6 +98,22 @@ public static function raw(Stringable|string $value, string $type, string $expre
self::getDumper()->raw($value, $expression ?? self::getExpression(__FUNCTION__), $type);
}
+ /**
+ * @param array $settings
+ */
+ public static function config(string $root, array $settings): void {
+ // Example?
+ self::getDumper();
+
+ // Update
+ $config = (array) config($root, []);
+ $config = (new ConfigMerger())->merge([ConfigMerger::Strict => false], $config, $settings);
+
+ config([
+ $root => $config,
+ ]);
+ }
+
private static function getExpression(string $method): ?string {
// File?
$context = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
diff --git a/dev/App/config/app.php b/dev/App/config/app.php
index 157097acf..71493f2ba 100644
--- a/dev/App/config/app.php
+++ b/dev/App/config/app.php
@@ -4,6 +4,7 @@
use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\Dev\App\Provider;
use LastDragon_ru\LaraASP\Documentator\Provider as DocumentatorProvider;
+use LastDragon_ru\LaraASP\Formatter\Provider as FormatterProvider;
use LastDragon_ru\LaraASP\GraphQL\Provider as GraphQLProvider;
use LastDragon_ru\LaraASP\Migrator\Provider as MigratorProvider;
use LastDragon_ru\LaraASP\Serializer\Provider as SerializerProvider;
@@ -32,7 +33,7 @@
| services the application utilizes. Set this in your ".env" file.
|
*/
- 'env' => env('APP_ENV', 'production'),
+ 'env' => env('APP_ENV', 'local'),
/*
|--------------------------------------------------------------------------
@@ -154,6 +155,7 @@
DocumentatorProvider::class,
MigratorProvider::class,
GraphQLProvider::class,
+ FormatterProvider::class,
])->toArray(),
/*