Weave 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

Php Utils Laravel Package

mll-lab/php-utils

A lightweight collection of PHP utility helpers from MLL Lab, offering convenient functions for arrays, strings, and common type checks. Framework-agnostic and easy to drop into any project to fill gaps in PHP's standard library.

View on GitHub
Deep Wiki
Context7

Getting Started

Add the package as a dev dependency if you are using it primarily for PHPStan rules:

composer require --dev mll-lab/php-utils:^7.0

Then include its PHPStan rules in phpstan.neon, after Larastan:

includes:
    - vendor/larastan/larastan/extension.neon
    - vendor/mll-lab/php-utils/rules.neon

Run PHPStan on a small path first:

vendor/bin/phpstan analyse app --memory-limit=1G

Where to look first: inspect vendor/mll-lab/php-utils/rules.neon and the package README/source to confirm which rules are enabled. The first practical use case is enforcing the package’s disallowed-call rules in CI, especially the new v7 rule that bans CarbonImmutable via PHPStan.

Implementation Patterns

  • Adopt the rules as a CI gate, not a big-bang cleanup. Add rules.neon, run PHPStan, generate a baseline for existing violations if needed, then fail CI on new violations. This keeps the upgrade from blocking delivery while still preventing new CarbonImmutable usage.

  • Pin the PHPStan toolchain together. v7 requires spaze/phpstan-disallowed-calls ^4.4, which requires PHPStan ^1.12.6. Upgrade Larastan/PHPStan together and verify the resolved versions:

    composer show larastan/larastan phpstan/phpstan spaze/phpstan-disallowed-calls
    
  • Handle CarbonImmutable deliberately. The new rule will flag existing CarbonImmutable imports/uses. Prefer migrating to the team-approved date type, or add a narrow, documented ignore only where immutable dates are an intentional architectural choice.

  • Extend the disallowed-call config for your app. Use spaze/phpstan-disallowed-calls configuration in your own phpstan.neon for project-specific bans such as dd(), dump(), raw env() outside config, or legacy helpers.

  • Keep Laravel integration at the edges. If you also use runtime helpers from this package, wrap vendor-specific calls in application services/actions rather than scattering them through controllers, Blade templates, or Eloquent models.

  • Run the same command locally and in CI. Add a Composer script so developers do not rely on IDE PHPStan integrations:

    "scripts": {
        "analyse": "phpstan analyse --memory-limit=1G"
    }
    

Gotchas and Tips

  • v7 is a breaking tooling upgrade. The main break is the spaze/phpstan-disallowed-calls requirement moving from ^2 to ^4.4. Older Laravel/PHPStan stacks may fail dependency resolution before PHPStan even runs.

  • Larastan 1.0.4 on PHP 8.0 is a known conflict. spaze/phpstan-disallowed-calls ^4.4 requires PHPStan ^1.12.6, while Larastan 1.0.4 allows PHPStan <1.9. Upgrade Larastan/PHPStan or stay on php-utils v6 for that environment.

  • The rule file is conditional on spaze being installed. v7 changed rules.neon inclusion to depend on whether spaze/phpstan-disallowed-calls is present, not only on the PHP version. If the new CarbonImmutable rule does not appear, verify spaze is actually installed and the include path is correct.

  • Clear PHPStan caches after changing includes. If rules seem stale:

    vendor/bin/phpstan clear-result-cache
    vendor/bin/phpstan analyse --debug
    
  • Do not blanket-ignore CarbonImmutable. A broad ignoreErrors entry hides the rule everywhere. Prefer targeted ignores with a comment explaining why immutable dates are required in that specific context.

  • Check CI matrix compatibility. If your matrix includes PHP 8.0 with old Larastan, either remove that combination from the PHPStan job or exclude the spaze extension there, matching the package’s own CI approach.

  • Treat this release as static-analysis governance first. The notable day-to-day impact is stricter PHPStan feedback and dependency alignment, not necessarily a runtime API change. Budget time for fixing or baselining new violations during the upgrade.

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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource