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

Stdlib Laravel Package

vanio/stdlib

Vanio Stdlib is a lightweight collection of reusable PHP utilities and helpers that reduce boilerplate in everyday development. It offers practical components for common data, string, and type tasks, making it useful in Laravel or standalone PHP projects.

View on GitHub
Deep Wiki
Context7

Getting Started

composer require vanio/stdlib

That is the whole install. There is no service provider, no config file, no publishable assets, no facade — which means it drops into a Laravel app without touching config/app.php or bootstrap/providers.php. The package is a small set of static helper classes under the Vanio\Stdlib namespace.

Where to look first: go straight to src/. Every class is one file and maps to exactly one gap in the PHP language; you can read the entire package in ten minutes. The three you will actually reach for are:

  • Vanio\Stdlib\Objects — equality, hashing, reflection-based property read/write, cloning
  • Vanio\Stdlib\Arrays — array shape detection (isSequential / isAssociative style checks)
  • Vanio\Stdlib\Strings — regex and substring helpers that return sane values instead of false plus by-ref $matches

First realistic use case: you have a value object and you are tired of hand-writing comparison chains or serializing it badly.

use Vanio\Stdlib\Objects;

final class Money
{
    private $amount;
    private $currency;

    public function equals($other): bool
    {
        return $other instanceof self && Objects::equals($this, $other);
    }
}

Then dedupe or key collections with Objects::getHash($money) instead of spl_object_hash(), which is identity-based and useless for two structurally equal instances.

Implementation Patterns

Value-object equality and hashing. Implement equals() by delegating to Objects::equals(), which walks properties (including private ones) recursively. Pair it with Objects::getHash() when building an in-memory set: $set[Objects::getHash($vo)] = $vo;. This is the single most defensible reason to install the package — it replaces a genuinely repetitive block of code in domain layers.

Generic property access for normalizers and test helpers. Objects::getPropertyValue($object, 'property') and the corresponding setter reach through visibility. Use this for generic serializers, CSV/Excel exporters, or test assertions against private state — the places where adding a public getter purely for tooling pollutes the API. Keep it out of production controller code; if a class needs its state read, that is a design signal, not a reflection problem.

Deciding JSON shape. Laravel's response()->json() and Eloquent's toArray() silently turn a sequential PHP array into a JSON list and an associative one into an object. Arrays::isSequential() / Arrays::isAssociative() let you assert the shape explicitly instead of relying on array_values($a) === $a, which is subtle enough that people get it wrong. This is a good guard in API resource classes and in tests.

Taming preg_match. Strings::match($subject, $pattern) style helpers return the matches (or null) rather than 0|1|false plus a by-ref $matches variable. Wrap the handful of regex checks you repeat across validators and parsers with these, and your call sites stop having three-branch error handling.

Testing. These are static calls with no state, so no mocking is needed, but they are also not mockable — which is fine for pure helpers and a design smell if you find yourself wanting to. Use them in PHPUnit data providers and fixture builders where brevity beats abstraction.

Laravel integration tip: because nothing here is container-aware, do not inject these classes via the container. Import the static class and call it. If you need it behind an interface (for a package you publish, or to swap for PHP 8 natives later), write a thin Str-style adapter of your own and call the static helper inside it.

Gotchas and Tips

PHP 8 has largely overtaken this package. str_contains, str_starts_with, str_ends_with, named arguments, and get_debug_type cover a chunk of what the Strings helper was written for in the PHP 7.1 era. If your project is on 8.x, audit which methods you actually still need; keeping the dependency for one function is not worth it.

It is unmaintained. Last release 2018, 3 stars, zero dependents. There is no CI against modern PHP, no security policy, no issue triage. Treat it as vendored code: pin an exact version in composer.json, and if you depend heavily on Objects, consider copying the two or three files you use into your own app/Support namespace. The classes are short enough that a fork is cheaper than a supply-chain risk.

Reflection breaks on typed, uninitialised properties. On PHP 7.4+, Objects::getPropertyValue() on a property declared private string $foo; before assignment throws an Error rather than returning null. This is the most common runtime surprise. Always confirm the object is fully hydrated (or use isset()/ReflectionProperty::isInitialized() yourself) before probing it.

Objects::getHash() is process-local. Whatever it derives from, do not persist it to a database, cache, or queue payload and expect it to match on the next request. Use it only as an in-memory array key.

Visibility bypass is a footgun, not a feature. Reflection ignores private, so refactors that rename a property will not fail at compile time — they fail at runtime, often deep in a serializer. Grep for property-name string literals before renaming anything on a class you touch with Objects::getPropertyValue().

No exception contract. These are 2018-era utilities: some methods return null, some return false, some trigger warnings on bad input. Read the method body before trusting the return type — there are no @throws guarantees to lean on.

Extension points are effectively nil. There is no plugin registry or config; if a helper almost does what you want, write your own wrapper class rather than subclassing a static utility. That wrapper also gives you the migration path off the package when you move to native PHP 8 functions.

Debugging tip: when a comparison misbehaves, dump both sides through Objects::getPropertyValue() in a loop rather than reaching for var_dump — recursive structures make raw dumps unreadable and Objects::equals() handles cycles where == will fatal.

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.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core