phpdot/path

Project-root discovery and named path resolution for PHPdot, configured via phpdot/config.

Maintainers

Package info

github.com/phpdot/path

Issues

pkg:composer/phpdot/path

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-07-17 23:14 UTC

This package is auto-updated.

Last update: 2026-07-18 03:25:02 UTC


README

Project-root discovery and named path resolution for PHPdot. Paths are declared in config/path.php, resolved to absolute paths at runtime, and reached through the PathRegistryInterface contract. The project root is written in at install time (or auto-detected from Composer), and unmapped names throw rather than being guessed.

Table of Contents

Requirements

Requirement Constraint
PHP >= 8.5
phpdot/config ^0.1
phpdot/package ^0.1

phpdot/container is a dev-only suggestion — the #[Config('path')] / binding attributes are inert until a phpdot application reflects them.

Installation

composer require phpdot/path

Usage

PathRegistry is a container singleton bound to PathRegistryInterface — inject the contract and read absolute paths by their name:

use PHPdot\Path\Contract\PathRegistryInterface;

$path = $container->get(PathRegistryInterface::class);

$path->base();          // /var/www/app
$path->config();        // /var/www/app/config
$path->vendor();        // /var/www/app/vendor
$path->public();        // /var/www/app/public
$path->protected();     // /var/www/app/protected
$path->get('uploads');  // /var/www/app/storage/uploads
$path->has('uploads');  // true

Every returned path is absolute. An unmapped name throws PathNotMapped — paths are explicit, never guessed.

Architecture

At install time phpdot/package scaffolds config/path.php and the PathInstaller install hook writes the absolute project root into base. At runtime ProjectRoot resolves the base (auto-detecting from Composer when base is empty) and PathRegistry resolves every named path to an absolute path.

graph TD
    CONFIG["config/path.php<br/><br/>base + named paths (PathsConfig defaults)"]
    INSTALL["PathInstaller  #[InstallHook]<br/><br/>writes the absolute project root into base"]
    ROOT["ProjectRoot<br/><br/>base, or auto-detected from Composer when empty"]
    REGISTRY["PathRegistry → PathRegistryInterface<br/><br/>resolves every name to an absolute path"]

    INSTALL --> CONFIG
    CONFIG --> ROOT
    ROOT --> REGISTRY
Loading

Testing

composer install
composer test        # PHPUnit
composer analyse     # PHPStan, level max + strict rules
composer cs-check    # PHP-CS-Fixer
composer check       # All three

License

MIT.

This repository is a read-only mirror, generated by CI from phpdot/monorepo. Pull requests and issues belong in the monorepo.