ProjectConfig
API reference › Scaffold › Config › ProjectConfig
Represents the consumer settings read from the project composer.json: extra.scaffold and config.vendor-dir.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$allowedPackages readonly constructor | list<string> | Package names allowed to write scaffold files, in declaration order. Default: []. | ProjectConfig |
$auto readonly constructor | bool | Whether the Composer hooks scaffold automatically. Default: true. | ProjectConfig |
$declared readonly constructor | bool | Whether extra.scaffold is an object. Default: false. | ProjectConfig |
$ignoredEntries readonly constructor | int | Number of non-string allowed-packages entries that were ignored. Default: 0. | ProjectConfig |
$vendorDir readonly constructor | string| | Non-empty config.vendor-dir as written in composer.json, or null when unset. Default: null. | ProjectConfig |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates consumer settings from scaffold configuration and the configured vendor-directory value. | ProjectConfig |
fromComposerJson() static | Reads the configuration from a composer.json file. | ProjectConfig |
fromExtra() static | Reads 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”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
| Parameter | Type | Description |
|---|---|---|
$allowedPackages | list<string> | Package names allowed to write scaffold files, in declaration order. |
$auto | bool | Whether the Composer hooks scaffold automatically. |
$ignoredEntries | int | Number of non-string allowed-packages entries that were ignored. |
$declared | bool | Whether extra.scaffold is an object. |
$vendorDir | string| | Non-empty config.vendor-dir as written in composer.json, or null when unset. |
fromComposerJson()
Section titled “fromComposerJson() ”public static function fromComposerJson(string $path): selfReads the configuration from a composer.json file.
Parameters
| Parameter | Type | Description |
|---|---|---|
$path | string | Absolute path to the project composer.json. |
Returns
self: Configuration from extra.scaffold and config.vendor-dir, or the defaults when they are absent.
Throws
RuntimeException: when the file is missing, unreadable, or not a JSON object.
fromExtra()
Section titled “fromExtra() ”public static function fromExtra(mixed[] $extra): selfReads the configuration from the extra section of the root package; only an explicit false in auto
disables the Composer hooks.
Parameters
| Parameter | Type | Description |
|---|---|---|
$extra | mixed[] | extra section of the root package. |
Returns
self: Configuration from extra.scaffold, or the defaults when it is absent or not an object.
isAllowed()
Section titled “isAllowed() ”public function isAllowed(string $packageName): boolReturns whether $packageName is listed in allowed-packages.
Parameters
| Parameter | Type | Description |
|---|---|---|
$packageName | string | Package name to check. |
Returns
bool: true when the package is allowed to write scaffold files, false otherwise.