PHPackages                             super-kernel/runtime-context - 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/runtime-context

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

super-kernel/runtime-context
============================

Runtime context and scoped path component for super-kernel.

03PHP

Since Apr 14Pushed 1mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

super-kernel/runtime-context
============================

[](#super-kernelruntime-context)

[![PHP Version](https://camo.githubusercontent.com/f2256a40fc8d71416dbb4019ea61cd707f7a76b02e48630f97cec75f06564fc6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d7e382e342e302d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/)[![Packagist Version](https://camo.githubusercontent.com/cd742cac55690cdd02ae707ca01893bb4a341906b45d647e1c8e4dc45d9753ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73757065722d6b65726e656c2f72756e74696d652d636f6e746578743f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/super-kernel/runtime-context)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](./LICENSE)[![GitHub Repo](https://camo.githubusercontent.com/9566a5defb251cd70324aad53d408421ecbfba1fb733d2e322f28cb421a6a725/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d73757065722d2d6b65726e656c25324672756e74696d652d2d636f6e746578742d3138313731373f6c6f676f3d676974687562)](https://github.com/super-kernel/runtime-context)

A runtime context and scoped path component for the **super-kernel** framework.

This package provides a small and stable public contract for detecting the current runtime environment, locating the runtime root path, and navigating paths safely within that root boundary.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Why This Package Exists](#why-this-package-exists)
- [Installation](#installation)
- [Requirements](#requirements)
- [Quick Start](#quick-start)
- [Public API](#public-api)
- [Runtime Modes](#runtime-modes)
- [Usage Examples](#usage-examples)
    - [Get the Current Runtime Context](#get-the-current-runtime-context)
    - [Determine the Runtime Mode](#determine-the-runtime-mode)
    - [Access the Runtime Root Path](#access-the-runtime-root-path)
    - [Resolve a Path from the Runtime Root](#resolve-a-path-from-the-runtime-root)
    - [Navigate Downward](#navigate-downward)
    - [Navigate Upward](#navigate-upward)
    - [Resolve Relative Paths Safely](#resolve-relative-paths-safely)
    - [Handle Runtime Context Exceptions](#handle-runtime-context-exceptions)
- [Path Safety Rules](#path-safety-rules)
- [Feature Matrix](#feature-matrix)
- [Architecture Overview](#architecture-overview)
- [Testing](#testing)
- [License](#license)

---

Features
--------

[](#features)

- Automatically detects the current runtime environment
- Supports Composer script runtime, Phar runtime, and CLI entry runtime
- Resolves the runtime root path automatically
- Provides a scoped path object for constrained path navigation
- Prevents escaping above the runtime root boundary
- Exposes a minimal and stable public contract
- Keeps runtime detection strategies internal
- Uses one public exception contract for all package-level failures

---

Why This Package Exists
-----------------------

[](#why-this-package-exists)

Runtime-dependent path handling is easy to get wrong when the same framework may run in multiple forms:

- through Composer
- through a Phar package
- through a direct CLI entry script

This package centralizes that responsibility.

Instead of scattering environment detection and path normalization logic across different components, consumers can rely on a single runtime context object and a single scoped path model.

---

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

[](#installation)

```
composer require super-kernel/runtime-context
```

---

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

[](#requirements)

- PHP `~8.4.0`

---

Quick Start
-----------

[](#quick-start)

```
