elasticms/helpers
PHP Helpers wraps and simplifies common PHP functions into PHPStan-compliant helpers, making static analysis easier and code safer across elasticMS projects. Part of the elasticMS monorepo, with docs and issue tracking available on GitHub.
Architecture fit. Despite the "Laravel/PHP package" framing in the metadata, this is not a Laravel package in any structural sense: there is no service provider, no config file, no facade, no container binding. It is a thin library of PHPStan-annotated wrappers (namespaced functions or static methods) around native PHP built-ins such as json_encode, file_get_contents, preg_match, array_merge. It will install cleanly into a Laravel app, but it competes with larastan's existing stubs for Str, Arr, and Collection. The genuine gap it fills is narrower: procedural/native calls in code paths Laravel already annotates well are not where teams struggle — the value is in filesystem, JSON, regex, and env handling, where native functions return broad unions like string|false.
Integration feasibility. Mechanically trivial: composer require, then swap call sites. The friction is ergonomic and cultural. If the helpers are namespaced free functions, every file needs use function imports, which is verbose and depresses organic adoption compared to a facade or static class. Whether the package registers anything globally (a real collision risk) must be confirmed before any trial. There is no evidence of a PHPStan extension or stub file, so the value proposition rests entirely on the annotations shipped in the source.
Technical risk. Four items dominate:
false/null. That is a behavioural change, not a cosmetic one. Code that checked if ($contents === false) now takes an uncaught exception path. Every swapped call site that can fail needs a test.The supplied product framing cites figures like "30–50% engineering effort," "15–20% velocity," and "<5% latency." None are sourced and none should be repeated to stakeholders. Treat them as unvalidated.
Key questions to resolve before a pilot:
false, or cast? Which exception types?phpstan/phpstan a runtime or dev dependency, and which PHPStan major version are the annotations written against (1.x vs 2.x annotation semantics differ)?Stack fit. Framework-agnostic; installs into any PHP 8.x codebase. Do not adopt it for string/array manipulation where Laravel's Str, Arr, and Collection already carry Larastan-compatible annotations. Adopt selectively for the "returns a union" native calls: JSON encode/decode, filesystem reads, regex matching, URL parsing, unserialize.
Migration path. A repository-wide codemod is the wrong move — high churn, destroyed git blame, enormous review surface, and no incremental value capture. Use a bounded pilot:
forbiddenFunctions entry so usage is enforced rather than aspirational; otherwise the package will be used in three files and forgotten.Compatibility. Pin to an exact version. Confirm the PHPStan major version alignment against your own toolchain (a Larastan upgrade often forces a PHPStan upgrade, which can silently invalidate the promised narrowing). Verify the PHP constraint against your oldest supported runtime.
Sequencing. License review and vendor health check first; pilot second; decision gate third; style-guide and enforcement last. The decision gate should explicitly include the build option: the realistic alternative to adoption is writing 10–15 typed wrappers in-house over one to two days. Given zero external dependents and a single-vendor upstream, in-house is a legitimate — and often the stronger — answer. It also keeps the exception contract under your control, which is precisely where the integration risk sits.
Maintenance. The repository is a read-only subtree split of the elasticMS mono repository; issues and pull requests are redirected there. Contribution cost is therefore not "open a PR" but "participate in a large third-party project's governance." Your maintenance burden is essentially zero, but so is your influence over the API.
Support. No commercial support identified, no published SLA, no external user base to draw on. Documentation lives on a vendor-run GitHub Pages site, not in the repo README. Assume you are self-supporting for anything beyond an obvious regression.
Scaling. The wrappers are thin, so per-call CPU cost is negligible in normal request paths. Two scaling caveats: (a) if wrappers perform validation or construct exceptions in tight loops over large datasets — exports, importers, queue workers — benchmark against the native call; (b) the throw-on-failure contract converts previously-silent bad data into 500s, which shifts load onto error handling and alerting. Confirm Laravel's exception handler treats the package's exception types sensibly (dontReport, error rendering, log noise) before enabling it in queue workers or scheduled jobs, where a raised exception is retried rather than surfaced.
Failure modes and mitigations.
composer install fails in CI. Mitigate by forking to an internal namespace, or vendoring the source and declaring a path or VCS repository with a committed fallback.Ramp-up. Low technical learning curve — roughly half a day for a mid-level developer to read the helper set and understand the exception contract. The real cost is a team-wide decision that has to be enforced in code review and CI for months to stick, and the ongoing cost of tracking a dependency whose release cadence is weekly but whose changelogs are empty.
How can I help you explore Laravel packages today?