PHPackages                             super-kernel/composer-package-registry - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. super-kernel/composer-package-registry

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

super-kernel/composer-package-registry
======================================

Composer installed package registry parser with per-package cache support for SuperKernel.

01PHP

Since Apr 15Pushed 1mo agoCompare

[ Source](https://github.com/super-kernel/composer-package-registry)[ Packagist](https://packagist.org/packages/super-kernel/composer-package-registry)[ RSS](/packages/super-kernel-composer-package-registry/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

super-kernel/composer-package-registry
======================================

[](#super-kernelcomposer-package-registry)

[![PHP Version](https://camo.githubusercontent.com/f2256a40fc8d71416dbb4019ea61cd707f7a76b02e48630f97cec75f06564fc6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d7e382e342e302d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/)[![Packagist Version](https://camo.githubusercontent.com/c71c16bbdb0b12762ac9ce4d083f02eed96bb439809b9a3a017b374b870ccb4a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73757065722d6b65726e656c2f636f6d706f7365722d7061636b6167652d72656769737472793f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/super-kernel/composer-package-registry)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](./LICENSE)[![GitHub Repo](https://camo.githubusercontent.com/d29d335b84b995c67e0f836276fedda73731cbb94737d8323cda54391f092da6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d73757065722d2d6b65726e656c253246636f6d706f7365722d2d7061636b6167652d2d72656769737472792d3138313731373f6c6f676f3d676974687562)](https://github.com/super-kernel/composer-package-registry)

A read-only Composer package registry component for **SuperKernel**.

It parses `composer.json` and `composer.lock` from a project root, resolves the root package and installed packages, scans package autoload metadata, and stores each scanned package as an independent cache file under the configured vendor directory. Path resolution is integrated with `super-kernel/runtime-context`, which acts as the runtime-root provider and the root-relative path adapter for project-level path operations.

Features
--------

[](#features)

- Parses the root package from `composer.json`
- Parses installed and dev-installed packages from `composer.lock`
- Treats the current project package as `root`, regardless of its declared Composer type
- Supports `psr-4`, `psr-0`, `classmap`, `files`, and `exclude-from-classmap`
- Keeps `autoload` and `autoload-dev` strictly separated
- Skips only the missing scan target, never the whole registry load because of a single missing autoload-dev path
- Skips package scanning when the physical package directory does not exist
- Caches each package independently under `{vendor}/.super-kernel/packages/`
- Reloads package objects from serialized cache files instead of returning the in-memory scan result directly

Requirements
------------

[](#requirements)

- PHP `~8.4.0`
- `super-kernel/runtime-context:dev-main`

Installation
------------

[](#installation)

```
composer require super-kernel/composer-package-registry
```

Package Types
-------------

[](#package-types)

This component uses interface constants instead of enums.

```
use SuperKernel\ComposerPackageRegistry\Contract\PackageTypeInterface;

PackageTypeInterface::ROOT;
PackageTypeInterface::LIBRARY;
PackageTypeInterface::METAPACKAGE;
PackageTypeInterface::CUSTOM;
```

Public Contracts
----------------

[](#public-contracts)

### `PackageInterface`

[](#packageinterface)

- `getName(): string`
- `getType(): string`
- `getRawType(): ?string`
- `getReference(): ?string`
- `isRoot(): bool`
- `isDev(): bool`
- `getComposerConfig(): array`
- `getRelativePath(): string`
- `getAutoload(): array`
- `getAutoloadDev(): array`
- `getFiles(bool $includeDev = true): array`
- `getClassMap(bool $includeDev = true): array`

### `PackageRegistryInterface`

[](#packageregistryinterface)

- `getRootPackage(): PackageInterface`
- `getPackages(): array`
- `getPackagesByType(string $type): array`
- `getPackage(string $name): ?PackageInterface`
- `hasPackage(string $name): bool`
- `hasDevPackages(): bool`
- `getVendorDirectory(): string`
- `getCacheDirectory(): string`

### `PackageRegistryLoaderInterface`

[](#packageregistryloaderinterface)

- `load(string $projectRoot): PackageRegistryInterface`
- `loadCurrentRuntimeProject(): PackageRegistryInterface`

Vendor Directory Resolution
---------------------------

[](#vendor-directory-resolution)

The vendor directory is resolved with the following priority:

1. `config.vendor-bin`
2. `config.vendor-dir`
3. `vendor`

Cache Layout
------------

[](#cache-layout)

Cache files are stored under:

```
{vendor-directory}/.super-kernel/packages/

```

Examples:

```
vendor/.super-kernel/packages/root-package.cache
vendor/.super-kernel/packages/psr/log.cache
vendor/.super-kernel/packages/symfony/console.cache

```

A package name such as `symfony/console` therefore becomes a nested cache path.

Cache Refresh Rules
-------------------

[](#cache-refresh-rules)

If a cache file already exists, it is refreshed when:

- the cached package reference is `null`, or
- the cached package reference differs from the currently installed reference

After refresh, the component reads the cache file again and returns the deserialized `PackageInterface` instance.

Scanning Rules
--------------

[](#scanning-rules)

### Missing package directory

[](#missing-package-directory)

If the resolved package directory does not exist, package scanning is skipped for that package only.

The package metadata still exists in the registry, but its scanned class map and files are empty.

### Missing `autoload` or `autoload-dev` scan targets

[](#missing-autoload-or-autoload-dev-scan-targets)

A missing path inside `psr-4`, `psr-0`, `classmap`, or `files` does **not** invalidate the package. Only that specific target is skipped.

This is especially important for `autoload-dev`: a missing dev path skips only the dev scan path, not the package scan.

Usage
-----

[](#usage)

```
