Skip to content

Loading configs from containers are not loaded/registered #224

@Gigiart

Description

@Gigiart

Apiato Core Version

13

PHP Version

8.2

Database Driver & Version

Maria DB last version

Fix: Apiato Core 13 Config Loading Issue - Path Separator Problem

Problem

Container configs were discovered correctly but not loaded into Laravel's config system due to mixed path separators on Windows.

Problem

Container configs were discovered correctly but not loaded into Laravel's config system due to mixed path separators on Windows.

Root Cause

The ConfigServiceProvider was using:

Str::of($path)->afterLast(DIRECTORY_SEPARATOR)->before('.php')->value()

The Fix:
File: vendor/apiato/core/Foundation/Support/Providers/ConfigServiceProvider.php

<?php

namespace Apiato\Foundation\Support\Providers;

use Apiato\Core\Providers\ServiceProvider;
use Apiato\Foundation\Apiato;

final class ConfigServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        foreach (Apiato::instance()->configs() as $path) {
            // FIX: Use basename() to handle mixed path separators
            $configKey = basename($path, '.php');
            $this->mergeConfigFrom($path, $configKey);
        }

        // Load core apiato config only if not already loaded
        $coreApiatoPath = __DIR__ . '/../../../../config/apiato.php';
        if (file_exists($coreApiatoPath) && config('apiato') === null) {
            $this->mergeConfigFrom($coreApiatoPath, 'apiato');
        }
    }

    public function boot(): void
    {
        $this->publishes([
            __DIR__ . '/../../../../config/apiato.php' => shared_path('Configs/apiato.php'),
        ], 'apiato-config');
    }
}

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions