Download the PHP package trehinos/thor-common without Composer
On this page you can find all versions of the php package trehinos/thor-common. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package thor-common
Thor Common
Reusable core utilities for the Thor framework (and standalone PHP projects).
This library provides small, focused components for day-to-day application code:
- Types: string helpers, arrays helpers, date/time helpers, placeholder formatting, a PSR-20-like clock interface
- Types\Collection: a fluent object wrapper around PHP arrays with many convenience methods
- Types\Safe\Option: an Option type (Some/None) to model optional values without nulls
- Types\Safe\Result: a small Result type (ok/error) inspired by Rust for safer error handling
- Configuration: ArrayObject-based configuration, YAML loader/writer, path interpolation
- Validation: simple filter/validator interfaces and a regex filter
- FileSystem: utilities for files, folders, and recursive operations
- Debug: a lightweight logger with log levels and throwable handling
- Encryption: GUID-like secure token generator
The components are decoupled; you can use only the parts you need.
API inventory (by namespace)
- Thor\Common\Types
- Strings: split, token, trimOrPad, left, right, prefix, suffix, interpolate(…, PlaceholderFormat)
- Arrays: turnOver
- DateTimes (implements ClockInterface): translate, getRelativeDateTime, period, get()->now()
- PlaceholderFormat (enum): CURLY, SIGIL, SHELL with helper to build placeholders
- ClockInterface: now()
- Thor\Common\Types\Collection
- Collection: vast fluent API over arrays (build/combine/fill/range, map/filter/reduce, slice/chunk, sort, unique, set ops, column, groupBy, indexBy, keys/values, etc.)
- Enums: SortOrder, SortFlag, UniqueSortFlag, FilterMode, KeyCase
- Thor\Common\Types\Safe
- Option and Maybe: Some/None optional value container with unwrap/match helpers
- Result and ResultState: ok/error result container with match helpers
- Thor\Common\Configuration
- ConfigurationFromFile: load/multipleFromFile/write for YAML-based config
- ConfigurationFolder: path interpolation via context
- Thor\Common\Validation
- FilterInterface, ValidatorInterface
- Filters\RegexFilter: PCRE-based validator/filter
- Thor\Common\FileSystem
- FileSystem: read/write/append helpers
- Folders: createIfNotExists, copyTree, removeTree
- Thor\Common\Debug
- Logger: PSR-3-like methods, static global instance, writeDebug, logThrowable
- LogLevel (enum)
- Thor\Common\Encryption
- Guid: random bytes with hex/base64 formats
Requirements
- PHP 8.3+
- Extensions: mbstring, openssl
- Composer dependencies: symfony/yaml, symfony/var-dumper (already declared)
Installation
Install via Composer:
Autoloading is PSR-4 under the Thor\Common namespace.
Quick start and examples
Below are small, practical examples for the most used utilities. All namespaces assume use statements or fully-qualified names as needed.
Types\Strings
-
Simple token interpolation with various placeholder syntaxes via PlaceholderFormat.
- Other helpers
Types\Arrays
Transpose/pivot a list of associative arrays into a dictionary of lists.
Types\DateTimes and ClockInterface
Formatting, relative display, periods, and a simple clock provider.
Types\Safe\Result
A minimal Result type to avoid throwing exceptions for expected errors.
Types\Safe\Option
A lightweight Option type to represent the presence (Some) or absence (None) of a value. Avoids passing raw nulls around and makes intent explicit.
Validation
FilterInterface and ValidatorInterface define small contracts. A ready-to-use RegexFilter is provided.
Configuration
ArrayObject-based configuration with YAML loading/writing and path interpolation.
Debug
A lightweight logger with log levels and an easy way to record throwables.
FileSystem
Convenience functions to work with files and folders.
Encryption
Secure random tokens and flexible string formats.
Types\Collection (fluent array wrapper)
A rich wrapper around PHP arrays offering dozens of familiar operations (map/filter/reduce, set ops, sorting, chunking, etc.).
Note: See the source of Types/Collection for the full list of methods and options.
Running tests
This repository uses PHPUnit 10.x. Install dev dependencies and run tests:
Versioning and stability
This package follows semantic versioning as much as possible. Minor versions may add features without breaking changes. Check the CHANGELOG or git history for details.
Contributing
Issues and PRs are welcome. Please include tests for bug fixes and new features when possible.
License
MIT License. See LICENSE file. © 2021–2025 Sébastien Geldreich
All versions of thor-common with dependencies
ext-mbstring Version *
ext-openssl Version *
symfony/yaml Version ^7
symfony/var-dumper Version ^7