Skip to content

ComposerScripts ​

php
final class Zairakai\LaravelDevTools\Services\ComposerScripts

Merges the Composer scripts of the package (stubs/composer-scripts.json) into the composer.json of a project.

A script that the project does not have is added. A script that the project has with another value is kept, unless $force is given. composer.json keeps the indentation that it has, and is not written when nothing changes.

Source: src/Services/ComposerScripts.php

Methods ​

merge() ​

php
public static function merge(string $composerJsonPath, string $stubPath, bool $force = false, callable $beforeWrite = null): array
ParameterDescription
$beforeWritecalled with the path of composer.json, before it is written over

Returns array{added: list<string>, updated: list<string>, skipped: list<string>}

Throws RuntimeException when composer.json or the stub is missing or cannot be read

Documentation of 5.5.0 , built from 92a7387 on 5.5.0 by pipeline #3086393151 on 2026-11-18.