Download the PHP package tihloh/prefab-core without Composer
On this page you can find all versions of the php package tihloh/prefab-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tihloh/prefab-core
More information about tihloh/prefab-core
Files in tihloh/prefab-core
Package prefab-core
Short Description Shared infrastructure for Prefab PHP modules: runtime, config, database, session, cache, contracts, diagnostics and CLI.
License MIT
Homepage https://github.com/tihloh/prefab-php
Informations about the package prefab-core
Prefab Core
prefab-core is the shared infrastructure layer used by Prefab feature modules.
It is not a business feature module. Applications normally install a feature package such as tihloh/prefab-users; Composer installs Core automatically as a dependency. You may also install Core directly when you only need its infrastructure APIs.
Core responsibilities
Core provides infrastructure shared across Prefab:
- runtime, configuration, capabilities, lifecycle and fluent-extension plumbing
- automatic
.envloading and environment-value access - universal fluent values through
val() - date/time convenience utilities
- database connections, PDO adapter, transactions, parameterized SQL and lightweight query building
- session storage through a small session contract and native PHP implementation
- cache contracts plus in-memory and file-backed cache implementations
- lightweight CLI command registration, argument/options parsing and terminal output
- diagnostics, tracing, redaction and debug rendering
- shared contracts and interoperability helpers
Core does not own user management, authentication rules, permissions, audit logging, routing, validation, file management, messaging or notifications. Those remain separate feature packages.
Universal values
val() wraps an ordinary PHP value with small fluent operations while keeping native PHP underneath.
The wrapper deliberately remains fluent so an operation can be extended safely:
Use value() only when external code specifically requires the native scalar/array value:
Nested data uses get():
Formatting is terminal and returns display text directly:
Prefab-owned database boundaries understand Value objects and unwrap them automatically:
An unresolved failed conversion is not silently written to the database; the boundary propagates the failure.
Environment (.env)
Core automatically looks for a .env file when Composer loads Prefab. Existing process/server values win over .env values.
Prefer Prefab's collision-safe accessor in reusable/framework-integrated code:
Values are also available through getenv() and $_ENV. A global env() convenience helper may be available when another library/application has not already defined it, but reusable Prefab code should prefer prefab_env() to avoid global-helper ownership conflicts.
A specific dotenv file can be loaded explicitly:
Date and time
Use Prefab's explicit helper when reusable code must avoid collisions with application/framework globals:
Date/time values can also be reached through val():
Common global names such as now() can conflict with helpers declared by an application or framework depending on Composer load order. Prefer the Prefab-prefixed API in reusable code.
Database
Database infrastructure is part of Core. New applications should use the Core namespace:
Core intentionally stays small: named PDO connections, parameterized SQL, transactions and a lightweight query builder. It is not an ORM and does not own models, relations, migrations or schema design.
Session
Authentication behavior remains in prefab-auth; Core only provides session mechanics.
Cache
Available lightweight stores include ArrayCache and FileCache.
CLI
Composer exposes Core's console executable as vendor/bin/prefab.
Linux/macOS:
Windows:
Register commands with:
When bootstrap/prefab.php exists in the current project directory, the CLI loads it before dispatching a command.
Runtime and diagnostics
Core owns the canonical Prefab runtime and diagnostics. Feature modules use the Core runtime instead of carrying duplicate infrastructure.
Normal trace:
Detailed trace:
Tracing is temporary developer diagnostics; persistent application/audit history belongs to Prefab Logs.
Development
The monorepo is the development source of truth. Package splitting publishes packages/core to tihloh/prefab-core.