# VendorDirResolver

> Resolves the Composer vendor directory of a project from COMPOSER_VENDOR_DIR, then config.vendor-dir in the project manifest (composer.json, or the file named by COMPOSER), then <project-root>/vendor.

[API reference](/docs/api/index.md) › [Scaffold](/docs/extensions/scaffold/reference/index.md) › [Config](/docs/extensions/scaffold/reference/config/index.md) › VendorDirResolver

| final class | `PHPForge\Scaffold\Config\VendorDirResolver` |
| --- | --- |
| Source | [`src/Config/VendorDirResolver.php`](https://github.com/php-forge/scaffold/blob/main/src/Config/VendorDirResolver.php#L17) |

Resolves the Composer vendor directory of a project from `COMPOSER_VENDOR_DIR`, then `config.vendor-dir` in the
project manifest (`composer.json`, or the file named by `COMPOSER`), then `<project-root>/vendor`.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`manifestName()`](#method-manifestName) static | Returns the file name of the project manifest: the `COMPOSER` environment variable when set, otherwise `composer.json`. | `VendorDirResolver` |
| [`manifestPath()`](#method-manifestPath) static | Returns the absolute path of the project manifest named by [`VendorDirResolver::manifestName()`](/docs/extensions/scaffold/reference/config/vendordirresolver/index.md#method-manifestName). | `VendorDirResolver` |
| [`resolve()`](#method-resolve) static | Returns the absolute path to the vendor directory for the project rooted at `$projectRoot`. | `VendorDirResolver` |

## Method details

### manifestName() <span id="method-manifestName"></span>

```php
public static function manifestName(): string
```

Returns the file name of the project manifest: the `COMPOSER` environment variable when set, otherwise
`composer.json`.

**Returns**

`string`: Manifest file name, relative to the project root unless the `COMPOSER` value is absolute.

### manifestPath() <span id="method-manifestPath"></span>

```php
public static function manifestPath(string $projectRoot): string
```

Returns the absolute path of the project manifest named by [`VendorDirResolver::manifestName()`](/docs/extensions/scaffold/reference/config/vendordirresolver/index.md#method-manifestName).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$projectRoot` | `string` | Absolute path to the project root directory. |

**Returns**

`string`: Absolute path of the project manifest.

### resolve() <span id="method-resolve"></span>

```php
public static function resolve(string $projectRoot, string|null $configured = null): string
```

Returns the absolute path to the vendor directory for the project rooted at `$projectRoot`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$projectRoot` | `string` | Absolute path to the project root directory. |
| `$configured` | `string\|null` | `config.vendor-dir` of the project manifest, or `null` when unset. |

**Returns**

`string`: Absolute path to the resolved vendor directory.