Download the PHP package ca-santos/laravel-support without Composer

On this page you can find all versions of the php package ca-santos/laravel-support. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-support

Laravel Support

A collection of small, dependency-light helpers for things almost every Laravel project ends up writing by hand: string/array/date/number formatting, casting request-style input, safe redirects, money and enum utilities, building Eloquent eager-load constraints, generating migrations at runtime, and hydrating plain PHP objects from arrays (including nested objects, Carbon dates, Collections and enums).

Everything is a plain static call — no service container bindings, no facades to fake in tests, no configuration to publish. This package only adds what Laravel doesn't already give you: nothing here duplicates a native Str, Arr, Number, or Eloquent method — where one already exists, use it directly instead.

Table of contents

Requirements

Installation

The service provider (CaueSantos\Support\ServiceProvider) is auto-discovered by Laravel — there is nothing to register or publish.

How this package is organized

Every class named XyzHelper lives under CaueSantos\Support\Helpers and exposes only public static methods — use the class and call it, nothing to instantiate:

A handful of classes live directly under CaueSantos\Support because they aren't stateless utility helpers — traits meant to be used on your own classes, small value objects, or tools with their own constructor/state (object hydration, migration generation). Those are documented in their own sections below.


StringHelper

CaueSantos\Support\Helpers\StringHelper — string generation and formatting that Laravel's own Str class doesn't cover.

Need to replace only the first occurrence of a substring, or slugify a string for a URL? Use Laravel's own Str::replaceFirst() / Str::slug() directly — this package used to wrap both, but they're already exactly what you need with no difference in behavior.

ArrayHelper

CaueSantos\Support\Helpers\ArrayHelper — recursive array transforms, plucking, key renaming, and tree building.

isListOfArrays() looks similar to Laravel's native Arr::isList() but checks something different: Arr::isList() only cares whether the keys are sequential, while isListOfArrays() additionally requires at least one element to itself be an array.

modifyRecursive(), mapRecursive(), buildPathArrays() and pluckGrouped() cover tree/menu-shaped data — see their docblocks in src/Helpers/ArrayHelper.php for the exact shape each one expects and returns (buildPathArrays() in particular returns one flattened list of every leaf's path segments, not one path-array per leaf — check its docblock before relying on the shape).

ObjectHelper

CaueSantos\Support\Helpers\ObjectHelper — deep array ⇄ stdClass conversion via a JSON round-trip.

DateHelper

CaueSantos\Support\Helpers\DateHelper — date validation/formatting and minute-to-hour formatting.

isValidDate() isn't the same as Carbon's own Carbon::hasFormat(): hasFormat() only checks that a string matches a format's shape — it actually returns true for Carbon::hasFormat('2024-02-30', 'Y-m-d'), an impossible date. isValidDate() round-trips the value back through the same format and rejects it if it doesn't match exactly, so it correctly returns false there.

For "now, in a given timezone", just use Laravel's own now('UTC') — no helper needed.

NumberHelper

CaueSantos\Support\Helpers\NumberHelper — byte formatting, memory usage, lightweight id generation, and clamping.

Laravel's own Number::fileSize() (Illuminate\Support\Number) looks similar but always pads to the given precision (Number::fileSize(1536, precision: 2) -> "1.50 KB"), where formatBytes() trims trailing zeros ("1.5 KB"). Pick whichever output style you want — they're genuinely different, not interchangeable.

MoneyHelper

CaueSantos\Support\Helpers\MoneyHelper — rounding-safe, cents-based money conversion and arithmetic. For currency formatting (symbols, locales), use Laravel's own Number::currency() instead — this class only covers what that doesn't: safe integer arithmetic.

ValueHelper

CaueSantos\Support\Helpers\ValueHelper — emptiness checks and instance-of checks that read better than nested ternaries.

ValidationHelper

CaueSantos\Support\Helpers\ValidationHelper — the one thing Laravel doesn't already give you a one-liner for: namespacing attributes for "each row of this array" validation rules.

To build a ValidationException from a plain attribute => message(s) array, just call Laravel's own \Illuminate\Validation\ValidationException::withMessages($errors) directly — it already accepts exactly that shape, no wrapper needed.

HtmlHelper

CaueSantos\Support\Helpers\HtmlHelper — small HTML-generation utilities.

FileHelper

CaueSantos\Support\Helpers\FileHelper — temp files, zip/unzip, CSV generation, MIME labels.

UrlHelper

CaueSantos\Support\Helpers\UrlHelper — external-vs-internal URL detection and open-redirect protection. Laravel doesn't ship anything for this out of the box.

EnumHelper

CaueSantos\Support\Helpers\EnumHelper — utilities for any PHP 8.1+ enum (backed or pure).

See also InteractsWithEnum to add these as methods directly on the enum itself.

CollectionHelper

CaueSantos\Support\Helpers\CollectionHelper — building nested Laravel Collections that support both array and object-style access.

EloquentHelper

CaueSantos\Support\Helpers\EloquentHelper — relation-loaded checks, model mapping, and closures for Eloquent's constrained eager loading.

SchemaHelper

CaueSantos\Support\Helpers\SchemaHelper — schema introspection, DDL helpers and SQL fragment building.

dropColumnIfExists() is portable across every driver Laravel supports (MySQL, MariaDB, Postgres, SQLite, SQL Server). The foreign-key methods are portable on Laravel 11+ (via Schema::getForeignKeys()), with a MySQL/MariaDB-only fallback on older versions — note that SQLite's foreign keys have no constraint name at all, so they can be detected but not dropped there. canBeHistorical() stays MariaDB-only: system versioning has no equivalent in MySQL, Postgres or SQL Server.

SqlHelper

CaueSantos\Support\Helpers\SqlHelper — parsing and analyzing raw SQL strings. Requires greenlion/php-sql-parser (see Optional dependencies).

LaravelHelper

CaueSantos\Support\Helpers\LaravelHelper — small, one-off framework integrations that don't warrant their own class.

CacheHelper

CaueSantos\Support\Helpers\CacheHelper — a cache-stampede-safe remember(). Requires a cache store that supports atomic locks (redis, memcached, database, dynamodb, or the array store).

Looking for a "serve stale data while refreshing in the background" strategy instead of blocking? That's Laravel's own Cache::flexible() — a different trade-off, not a replacement for this.

LabelHelper

CaueSantos\Support\Helpers\LabelHelper — tiny display-label formatting.

SseHelper

CaueSantos\Support\Helpers\SseHelper — a minimal Server-Sent Events response helper.


Object hydration

Two traits and one static class work together to fill a plain PHP object's typed properties from an array — casting scalars to their declared type, parsing dates into Carbon, resolving enums, building nested Collections, and recursively hydrating nested typed objects.

Model traits (HasSlug, HasMetadata)

HasSlug auto-generates a slug column from another attribute when a model is created, appending -2, -3, etc. if it would otherwise collide:

HasMetadata gives a model a flexible, dot-notation-aware key-value store backed by a single JSON column (default: meta — cast it to array):

InteractsWithEnum

use on a backed or pure enum to add a default label() derived from the case name, plus options()/values()/names() static passthroughs to EnumHelper. Override label() on the enum itself for custom per-case labels.

Makeable objects (IsMakeable, Component)

IsMakeable is a one-method trait: use it on any class to get a ::make(...$arguments) static constructor that just forwards to new static(...$arguments) — handy for a fluent, static-friendly construction style.

Component is a tiny, ready-made value object built on IsMakeable for describing a named UI component with its data — e.g. handing a Blade/Inertia component name and props around as a single value:

Runtime migration generation

RuntimeMigration builds a real Laravel migration file (not a migration run in-process) from a Blueprint closure, so you can generate migrations programmatically — e.g. from a schema-builder UI, an artisan command, or a code generator.

If the target directory doesn't exist, or the file can't be written, create()/update() throw CaueSantos\Support\Exceptions\MigrationGenerationException.

Two smaller pieces support this:

Optional dependencies

Two methods need a package this library doesn't force on every consumer — both are declared under Composer's suggest, not require, so install them only if you actually call the method that needs them:

Package Needed for
greenlion/php-sql-parser SqlHelper::getExpressionByAlias()
inertiajs/inertia-laravel LaravelHelper::forceInertiaRedirect()

Testing & code quality

All three run in CI on every push and pull request, across a PHP 8.2–8.4 matrix (see .github/workflows/).

Security

If you discover any security related issues, please email instead of using the issue tracker.

License

MIT. See LICENSE.


All versions of laravel-support with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ca-santos/laravel-support contains the following files

Loading the files please wait ...