Skip to content

Commit

Permalink
feat: add empty config
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed Mar 27, 2024
1 parent dc64b68 commit d363cee
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Bridge/Laravel/Providers/PackageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,32 @@
namespace WayOfDev\Package\Bridge\Laravel\Providers;

use Illuminate\Support\ServiceProvider;
use WayOfDev\Package\Config;

final class PackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../../../../config/package.php' => config_path('package.php'),
Config::path() . Config::fileName() => config_path(Config::fileName()),
], 'config');

$this->registerConsoleCommands();
}
}

public function register(): void
{
// @phpstan-ignore-next-line
if (! $this->app->configurationIsCached()) {
$this->mergeConfigFrom(
Config::path() . Config::fileName(),
Config::key()
);
}
}

private function registerConsoleCommands(): void
{
$this->commands([]);
Expand Down
27 changes: 27 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace WayOfDev\Package;

use WayOfDev\Package\Contracts\ConfigRepository;

class Config implements ConfigRepository
{
private const KEY = 'package';

public static function fileName(): string
{
return self::KEY . '.php';
}

public static function key(): string
{
return self::KEY;
}

public static function path(): string
{
return __DIR__ . '/../config/';
}
}
9 changes: 9 additions & 0 deletions src/Contracts/ConfigRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace WayOfDev\Package\Contracts;

interface ConfigRepository
{
}

0 comments on commit d363cee

Please sign in to comment.