Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Helpers Laravel Package

elasticms/helpers

View on GitHub
Deep Wiki
Context7

[READONLY] enclose regular PHP functions in PHPStan compliant functions

Frequently asked questions about Helpers
How does this package improve Laravel applications beyond native PHP functions?
This package wraps core PHP functions (e.g., `array_merge`, `json_encode`) with PHPStan-compliant signatures, reducing type-related errors in Laravel services, controllers, and utility layers. Unlike Laravel’s Str/Arr helpers, it targets lower-level functions where Laravel lacks typed alternatives, making static analysis more effective without altering framework behavior.
Do I need PHPStan installed to use this package?
Yes, the package’s value depends on PHPStan. Without it, you’ll gain minimal benefits—only the convenience of wrapped functions. If your Laravel project doesn’t use PHPStan, consider adopting it first via `phpstan/extension-installer` or evaluating alternatives like PestPHP’s type-checking features.
Will this package break existing Laravel code that uses native PHP functions?
No, it’s a drop-in replacement. Replace `array_merge()` with `Helpers::arrayMerge()` in your codebase, but expect PHPStan to flag type mismatches (e.g., mixed return types). Test thoroughly, especially in legacy code, as stricter typing may expose hidden issues. Start with high-churn utility functions to minimize risk.
Does this work with Laravel’s built-in helpers like `Arr::` or `collect()`?
Yes, it’s designed to complement Laravel’s helpers. Use `Helpers::arrayFilter()` for typed array operations in services, then chain with `collect()` for fluent transformations in controllers. For example, `Helpers::arrayMap($items, fn($item) => $item->toArray())->toJson()` combines type safety with Laravel’s fluent syntax.
What Laravel versions and PHP versions are supported?
The package targets Laravel 9+ (PHP 8.1+) and Laravel 10+ (PHP 8.2+), aligning with PHPStan’s latest compatibility. Check the [documentation](https://ems-project.github.io/#/dev/helpers/index.md) for exact version constraints, but it avoids Laravel-specific dependencies, so it integrates seamlessly with any modern Laravel app.
Are there performance concerns with wrapped functions?
Overhead is minimal (~0–5%), but benchmark critical paths (e.g., bulk data processing) to ensure compliance with SLAs. The wrappers add static type safety at runtime, which may slightly slow execution compared to native functions. For performance-critical code, weigh the trade-off against PHPStan’s long-term benefits.
How do I migrate from native PHP functions to this package?
Start by identifying PHPStan errors in your Laravel project (e.g., `array_merge` with mixed arguments). Replace them one by one with `Helpers::` equivalents, then run PHPStan to catch remaining issues. Use IDE refactoring tools to automate replacements. Prioritize utility files and services where type safety is most valuable.
Can I use this package without PHPStan in a Laravel project?
Technically yes, but you’ll miss the core benefit—type safety. Without PHPStan, the package only provides syntactic sugar for common functions. If your goal is stricter typing, pair it with PHPStan in CI/CD (e.g., GitHub Actions) to catch errors early. Alternatives like `rubix/ml` or `spatie/array-to-object` may offer broader functionality if PHPStan isn’t a priority.
What if the package’s type constraints conflict with my business logic (e.g., null returns)?
The package enforces strict typing by default, but you can override constraints in PHPStan’s config (e.g., `@var non-empty-array` for optional fields). Document edge cases in your codebase and use runtime validation (e.g., `Arr::where()`) for critical paths. Balance static analysis with practical business needs—PHPStan is a tool, not a rigid rule.
Is this package actively maintained? What if it’s abandoned?
As of now, the package has no stars or dependents, indicating low adoption. Monitor the [elasticMS repo](https://github.com/ems-project/elasticms) for updates, and consider forking it if activity stalls. For critical projects, evaluate alternatives like `spatie/array-to-object` or rewrite wrappers in-house to avoid dependency risks. Long-term viability depends on the elasticMS team’s commitment.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views