lyhty/support
Adds some very convenient helpers to your Laravel project
8,475
| Install | |
|---|---|
composer require lyhty/support |
|
| Latest Version: | v4.1.0 |
| PHP: | ^8.2 |
| License: | MIT |
| Last Updated: | Jun 17, 2026 |
| Links: | GitHub · Packagist |
Maintainer: TruecapeDev
This package provides some additional, convenient helpers for you to use in your Laravel project.
Installation
Install the package with Composer:
composer require lyhty/support
Features
Helpers
class_has_attribute(object|string $class, string $attribute): bool- Return boolean value whether the given class has given attribute.
class_uses_trait(object|string $class, string $trait, bool $recursive = true): bool- Return boolean value whether the given class uses given trait.
array_depth(array $array): int- Return integer describing the max depth of the given array.
class_implements_interface(object|string $class, string $interface): bool- Return boolean value whether the given class implements given interface.
class_extends(object|string $class, string $parent): bool- Return boolean value whether the given class extends given parent class.
set_type(mixed $value, string $type): mixed- Alias for 'settype' which allows non-variables as arguments.
trim_spaces(string $string): string- Trim spaces from string.
not_null(mixed $var): bool- !is_null
get_bool(mixed $value): bool- Get boolean value from given value. Accepts string true/false.
class_namespace(string $className): string- Get namespace of given class.
___(array $keys, array $replace = [], array $numbers = [], string $locale = null, string $glue = ' '): string- Translate given messages and glue them together.
Discovery class
This is pretty much copied from Illuminate\Foundation\Events\DiscoverEvents from, just made more
generic.
Examples
use Lyhty\Support\Discovery;
$all = Discovery::within('app\Models')->toArray();
// ["App\Models\User", "App\Models\BlogPost", "App\Models\Concerns\Taggable", "App\Models\Contracts\BlogWriter"]
$classes = Discovery::classesWithin('app\Models')->toArray();
// ["App\Models\User", "App\Models\BlogPost"]
$traits = Discovery::traitsWithin('app\Models')->toArray();
// ["App\Models\Concerns\Taggable"]
$interfaces = Discovery::interfacesWithin('app\Models')->toArray();
// ["App\Models\Contracts\BlogWriter"]
$usingClasses = Discovery::usesWithin('app\Models', 'App\Models\Concerns\Taggable')->toArray();
// ["App\Models\BlogPost"]
$implementingClasses = Discovery::implementsWithin('app\Models', 'App\Models\Contracts\BlogWriter')->toArray();
// ["App\Models\User"]
$extendingClasses = Discovery::extendsWithin('app\Models', 'Illuminate\Database\Eloquent\Model')->toArray();
// ["App\Models\User", "App\Models\BlogPost"]
License
Lyhty Support is open-sourced software licensed under the MIT license.
Related Packages
dragon-code/support
Support package is a collection of helpers and tools for any project.
12,296,119
23
michele-angioni/support
Support is a Laravel package which promotes the use of best practices and design...
1,460
18
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v4.1.0 | ^8.2 | ^12.0 | | MIT | |
| v4.0.2 | ^8.2 | ^12.0 | | MIT | |
| v4.0.1 | ^8.2 | ^12.0 | | MIT | |
| v4.0.0 | ^8.2 | ^12.0 | | MIT | |
| v3.0.1 | ^8.2 | ^11.0 | | MIT | |
| v3.0.0 | ^8.2 | ^11.0 | | MIT | |
| v2.2.0 | ^7.4 | | ^8.0 | | MIT | |
| v2.1.0 | ^7.4 | | ^8.0 | | MIT | |
| v2.0.1 | ^7.4 | | ^8.0 | | MIT | |
| v2.0.0 | ^7.4 | | MIT | ||
| v1.0.0 | >=7.1.3 | >=5.6 | MIT |