adachsoft / project-workspace
Project workspace path mapping and repository adapter
Requires
- php: ^8.3
- adachsoft/command-executor-lib: ^2.3
- adachsoft/project-config-lib: ^0.1.0
Requires (Dev)
- adachsoft/php-code-style: ^0.8.0
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A PHP library for translating project paths between canonical and local workspace locations and for preparing project workspaces from Git repositories.
Features
- Parse ordered, semicolon-separated absolute path mappings and convert paths in either direction.
- Decorate a project configuration repository to transparently map project paths when reading and writing definitions.
- Read Git origin URLs, normalize supported GitLab URLs, and synchronize URLs with project configuration.
- Clone configured repositories into workspaces and optionally install detected Composer and npm dependencies.
Installation
Install the library with Composer:
composer require adachsoft/project-workspace
Composer installs the required AdachSoft command-execution and project-configuration libraries as dependencies.
Requirements
- PHP 8.3 or later.
- Composer.
Usage
Use PathMappingParser to parse configured path mappings and PathMappingProjectConfigRepository to apply them to project configuration access.
Integration
Parse a mapping value supplied by your application's configuration, then translate a canonical project path to its local workspace path:
use AdachSoft\ProjectWorkspace\PathMappingParser;
$mappingValue = '/srv/projects/=/workspace/projects/';
$pathMapping = (new PathMappingParser())->parse($mappingValue);
$localPath = $pathMapping->toLocal('/srv/projects/example');
// $localPath is '/workspace/projects/example'
To apply path translation throughout project configuration access, wrap an existing ProjectConfigRepositoryInterface implementation with PathMappingProjectConfigRepository and provide the parsed PathMapping. The decorator maps base_path values on reads and writes while preserving the rest of each project definition.
See the usage examples for additional integration details.