Skip to content

StreamServiceProvider::registerAddons #740

@RobinRadic

Description

@RobinRadic

The composer vendor dir path might be usefull in other places, like third party addons. I recommend

        $composer = json_decode(file_get_contents(base_path('composer.json')), true);
        $lock = json_decode(file_get_contents(base_path('composer.lock')), true);

        if ($directory = Arr::get($composer, 'config.vendor-dir')) {
            $directory = base_path($directory);
        }
        
        if (!$directory) {
            $directory = base_path('vendor');
        }

the directory value coming from this to be bound in container. So it is re-usable. No need to check this twice.

I also recommend adding the JSON_THROW_ON_ERROR flag:

json_decode(file_get_contents(base_path('composer.json')), true,512,JSON_THROW_ON_ERROR);

This will make developers not only aware that something is wrong, but where the error is located

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions