Skip to content

ComposerJson ​

php
final class Zairakai\LaravelDevTools\Services\ComposerJson

Reads and writes the composer.json of a project, and the scripts in it, with the indentation that the file has.

Source: src/Services/ComposerJson.php

Methods ​

encode() ​

php
public static function encode(array $composer, string $original): string

json_encode indents with 4 spaces: the output is indented as the file was (2 spaces when it cannot be told).

read() ​

php
public static function read(string $path): array

Returns array{string, array<string, mixed>} the text of the file, and what it decodes to

Throws RuntimeException when the file is missing or cannot be read

scripts() ​

php
public static function scripts(array $composer): array

Returns array<string, mixed>

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