nette/utils
nette/utils is a collection of handy PHP utilities used by the Nette Framework: string and array helpers, smart objects, reflection, file system, JSON/HTML tools, callbacks, and more. Lightweight, dependency-free components that simplify everyday PHP development.
Strings::webalize() for Unicode-aware slugs, Validators for emails/URLs/identifiers, FileSystem::isValidFilename() for upload safety, and Json for consistent encode/decode error handling.exec()/shell_exec() calls with Process::runExecutable() (argument arrays, no shell) reduces injection risk. Centralized filename validation reduces path traversal, control-character, and Windows reserved-name issues.Image covers lightweight GD-based resizing, type detection, and basic drawing. The decision is whether that is sufficient versus adopting Intervention Image, Glide, or a hosted image service for advanced transformations, caching, and format coverage.Adopt when:
Strings::webalize() requires intl), strict/safe JSON decoding, cross-platform filename validation, image type detection and simple GD operations, iterable helpers (Iterables::memoize(), mapWithKeys()), and float comparison (Floats).Look elsewhere when:
Str, Arr, Validator, Symfony Process, Flysystem/File, and Laravel’s JSON response handling. Adding nette/utils for overlapping functions increases dependency surface with limited product benefit.For executives: nette/utils is a small, mature, framework-agnostic PHP utility library that helps us ship common features faster — slug generation, safe file uploads, JSON parsing, lightweight image handling, and controlled subprocess execution — with less custom code and fewer security edge cases. It is low-risk to evaluate: no framework lock-in, active releases (most recently v4.1.4, with the 4.0 branch adding PHP 8.6 support), documented changes, and static analysis in CI. The main adoption considerations are the PHP 8.2 floor for v4.1 and license confirmation, since GitHub reports NOASSERTION. Recommended approach: time-boxed pilot in one service, measure delivery speed and defect reduction, then standardize only where it replaces custom code — not where Laravel already provides equivalent functionality.
For engineering: treat this as a targeted utility layer, not a framework replacement. Highest-value adoptions are Strings (Unicode and slugging), Validators, Json (strict decoding), FileSystem::isValidFilename(), Image for simple GD tasks, and selected Iterables/Floats helpers. Avoid duplicating Laravel/Symfony capabilities — especially Symfony Process, Str, and Arr — unless there is a clear behavioral win. Pin versions and the minor branch explicitly (4.0 vs 4.1 have different PHP floors; 4.0.11 adds PHP 8.6 support, which is a compatibility signal, not a feature change), require the correct PHP minimum, run PHPStan, and wrap third-party calls behind small internal adapters so we can swap implementations later. Watch for breaking changes across majors: v4 changed DateTime strictness and requires intl for webalize(). Confirm license terms before production use.
How can I help you explore Laravel packages today?