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.
Architecture fit
Strings, Arrays, Validators, Json, FileSystem, Image, Process, DateTime, Iterables, Type) with no container bindings, no configuration, and no service provider. It sits below the application layer and imposes no architectural opinion on a Laravel codebase.Illuminate\Support (Str, Arr), Laravel's Validator, Illuminate\Process, and Illuminate\Support\Facades\File. Adopting it means running two utility conventions in parallel unless a standard is set.Integration feasibility
composer require nette/utils:^4.1 with PSR-4 autoloading. Effort for a pilot is measured in hours, not sprints.ext-intl (Strings::webalize() became INTL-required in 4.1.0), ext-gd (Image), mbstring/iconv (strings length/transliteration fallbacks), and proc_open availability for Process.Process API is the highest-value differentiator: Process::runExecutable() passes arguments as an array with no shell involvement, eliminating shell-injection risk by construction, and supports timeouts, incremental output consumption, and exit-code checks across Windows and POSIX.Technical risk
NOASSERTION; the library is understood to be BSD-family but the metadata does not confirm it. This requires legal review before production use and is a hard gate, not a formality.Strings, FileSystem, Json, and Process are static classes, so unit tests cannot substitute them. Code that calls them directly becomes harder to isolate; adapters are needed wherever behavior must be faked.release_tag: v4.1.4 with release notes for v4.0.11, and the previously recorded last-release date (2026-07-17) is forward-dated while the current record says 2026-05-11. Combined with Dependents: 0 for a 2.1k-star library that is a transitive dependency of much of the PHP ecosystem, this data should not drive dependency-governance decisions. Verify tag, changelog, and PHP constraint directly against Packagist/GitHub.Reflection::getReturnType()/getParameterType()/getPropertyType(), made DateTime strict (explicit BC break), PascalCased constants, and rewrote Finder. Pinning to ^4.1 and gating minor bumps through changelog review is mandatory.Str::slug(), others Strings::webalize(), producing inconsistent slug output and untranslatable content across features.Key questions
NOASSERTION license status, and what is the approved license set for production dependencies?Process, FileSystem::isValidFilename(), and strict Json, or is this opportunistic adoption?ext-intl and ext-gd present and pinned in production, staging, and CI container images?symfony/process or Illuminate\Process usage we would be duplicating or replacing?DateTime or Json?runExecutable() path specifically, and are there current call sites using shell_exec/exec that should be migrated?Stack fit
Illuminate\Support. The clearest non-overlapping wins:
Process — shell-injection-safe invocation of external binaries (PDF renderers, media encoders, git, container tooling) with native timeout and streaming output.FileSystem::isValidFilename() — no Laravel equivalent; rejects path separators, control/reserved characters, trailing dots and spaces, and Windows device names (CON, LPT1). Directly useful on the upload path.Json::decode()/encode() and Json::decodeFile() — consistent exception-based failure handling instead of json_decode() returning null.Strings::webalize() — transliterating, INTL-backed slugging where ASCII-only Str::slug() output is insufficient for non-Latin content.Image — GD-based resize/type detection for lightweight avatar and thumbnail work without pulling in a heavier imaging package.Arrays vs Arr (use Arr for consistency with Eloquent/Collection code), Validators vs Laravel's Validator (form validation stays in Laravel), Html (Blade escapes already).Migration path
Str/Arr/Validator call sites is required or recommended as part of adoption.ProcessRunner interface with a nette-backed implementation, registered in a service provider. This preserves testability while keeping the library out of business logic.Nette\Utils\* imports to the App\Support namespace.Compatibility
^4.1 and treat minor bumps as reviewable changes, not automatic.composer why-not nette/utils ^4.1 before rollout to catch transitive PHP-version or extension conflicts; confirm no existing dependency already pins an older nette/utils major.intl, gd, mbstring) in composer.json require/suggest and in the Dockerfile, so failures occur at build time rather than at runtime.Sequencing
FileSystem::isValidFilename() on upload validation and Json::decode() on inbound webhook payloads. Low blast radius, immediate security value, exercises deployment.ProcessRunner adapter, migrate the highest-risk existing shell invocations, add timeout and exit-code assertions, and instrument failures.Iterables::memoize(), Arrays::mapWithKeys(), Helpers::clamp() adopted opportunistically, and only where profiling or readability justifies it.Maintenance
DateTime, Json, Strings, or Process.DateTime, Json, and Strings at minor bumps, plus tracking fixes that land on only one of the two maintained lines.Support
Finder symlink issues under Windows are a documented upstream quirk) and locale-dependent DateTime parsing.Scaling
Process under queue workers: concurrency must be bounded by worker count and process timeouts; unbounded subprocess spawning is the primary scaling hazard.Image under concurrent uploads: GD holds decoded bitmaps in memory, so large-image requests can spike worker memory far above baseline. Enforce upload size limits before decode.FileSystem operations on shared or networked storage inherit that storage's latency and locking behavior.Failure modes
ext-intl — Strings::webalize() fails where Str::slug() previously worked; surfaces only on the affected code path. Detect at build time via composer platform requirements.ext-gd — Image operations fail; 4.0.5 added GD detection, so this can be surfaced as a health check rather than a runtime surprise.DateTime strictness — v4 throws on input that v3 tolerated. Any user-supplied date string is a potential exception path; wrap and validate at the boundary.Json exceptions — exception types and depth/flag semantics differ from native json_decode(); webhook handlers that previously received null will now throw. This is an improvement but a behavioral change requiring explicit catches.Process timeouts and exit codes — a killed subprocess yields a non-zero exit and partial output; the consuming job must distinguish timeout from genuine failure, and must always terminate the process on abandoned jobs to avoid orphans.FileSystem runtime exceptions — permission and mode failures throw rather than returning false, so upload and write paths need explicit handling.$warnings parameter to Image::fromFile()/fromString(), so GD warnings can be logged instead of emitted as PHP warnings. Adopt this parameter rather than relying on @ suppression.Ramp-up
Str here, Strings there"), and a code-review checklist.Process migration while timeout and error-handling behavior is tuned against real workloads; plan for it in the first sprint rather than treating it as a defect.How can I help you explore Laravel packages today?