Skip to content
PHP Ecosystem
Explore

ProjectConfig

API reference › Scaffold › Config › ProjectConfig

final readonly classPHPForge\Scaffold\Config\ProjectConfig
Sourcesrc/Config/ProjectConfig.php

Represents the consumer settings read from the project composer.json: extra.scaffold and config.vendor-dir.

PropertyTypeDescriptionDefined by
$allowedPackages readonly constructorlist<string>Package names allowed to write scaffold files, in declaration order. Default: [].ProjectConfig
$auto readonly constructorboolWhether the Composer hooks scaffold automatically. Default: true.ProjectConfig
$declared readonly constructorboolWhether extra.scaffold is an object. Default: false.ProjectConfig
$ignoredEntries readonly constructorintNumber of non-string allowed-packages entries that were ignored. Default: 0.ProjectConfig
$vendorDir readonly constructorstring|nullNon-empty config.vendor-dir as written in composer.json, or null when unset. Default: null.ProjectConfig
MethodDescriptionDefined by
__construct()Creates consumer settings from scaffold configuration and the configured vendor-directory value.ProjectConfig
fromComposerJson() staticReads the configuration from a composer.json file.ProjectConfig
fromExtra() staticReads the configuration from the extra section of the root package; only an explicit false in auto disables the Composer hooks.ProjectConfig
isAllowed()Returns whether $packageName is listed in allowed-packages.ProjectConfig
public function __construct(list<string> $allowedPackages = [], bool $auto = true, int $ignoredEntries = 0, bool $declared = false, string|null $vendorDir = null)

Creates consumer settings from scaffold configuration and the configured vendor-directory value.

Parameters

ParameterTypeDescription
$allowedPackageslist<string>Package names allowed to write scaffold files, in declaration order.
$autoboolWhether the Composer hooks scaffold automatically.
$ignoredEntriesintNumber of non-string allowed-packages entries that were ignored.
$declaredboolWhether extra.scaffold is an object.
$vendorDirstring|nullNon-empty config.vendor-dir as written in composer.json, or null when unset.
public static function fromComposerJson(string $path): self

Reads the configuration from a composer.json file.

Parameters

ParameterTypeDescription
$pathstringAbsolute path to the project composer.json.

Returns

self: Configuration from extra.scaffold and config.vendor-dir, or the defaults when they are absent.

Throws

public static function fromExtra(mixed[] $extra): self

Reads the configuration from the extra section of the root package; only an explicit false in auto disables the Composer hooks.

Parameters

ParameterTypeDescription
$extramixed[]extra section of the root package.

Returns

self: Configuration from extra.scaffold, or the defaults when it is absent or not an object.

public function isAllowed(string $packageName): bool

Returns whether $packageName is listed in allowed-packages.

Parameters

ParameterTypeDescription
$packageNamestringPackage name to check.

Returns

bool: true when the package is allowed to write scaffold files, false otherwise.