Download the PHP package coyote6/laravel-str without Composer

On this page you can find all versions of the php package coyote6/laravel-str. 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-str

Laravel Str

Latest Version on Packagist Tests

Extends Laravel's Str facade with a handful of extra macros: case converters (dot, pureKebab, pureSnake, strictKebab, strictSnake) and a set of is* checks for detecting what case a string is already in.

Requirements

The floor is illuminate/support 10.0, since that's the first version where Str::slug() accepts both $language and $dictionary (added between v9.0.0 and v10.0.0) — isSlug() mirrors that full signature. Str::kebab() and Str::slug()'s $language argument are both much older (present since at least Laravel 7), so this floor covers them comfortably.

Str::studly()'s $normalize parameter is newer still — not even in v13.0.0, only added in a recent 13.x point release. isStudly() detects at runtime whether the installed version supports it and throws a clear exception if $normalize is requested but unsupported, rather than silently ignoring it (PHP drops unknown trailing arguments instead of erroring).

CI tests PHP 8.4 (the only version pestphp/pest ^5.0 itself can install on) against both the lowest and latest resolvable dependency versions — currently illuminate/support 10.0.0 and whatever the latest 13.x release is, respectively.

Installation

The package registers Coyote6\LaravelStr\Providers\StrServiceProvider automatically via Laravel's package discovery — no manual provider registration needed.

Available Methods

Methods

Str::dot()

The dot method converts the given string to dot.case. Any run of characters that isn't a letter or number (spaces, punctuation, dashes, underscores, etc.) is collapsed into a single dot, and any leading or trailing dots are trimmed.

This is commonly useful for turning human-readable permission or ability names into machine keys:

Str::isCamel()

The isCamel method determines if the given string is already in camelCase.

Str::isDot()

The isDot method determines if the given string is already in dot.case. It checks the string against the output of Str::dot().

Str::isKebab()

The isKebab method determines if the given string is already in kebab-case.

Note: Str::kebab() only inserts a dash at case-boundary transitions — it never validates or collapses the separators already in the string. That means Str::isKebab('a_kebab_like_string') and Str::isKebab('a--kebab--like--string') both return true, even though neither looks like clean kebab-case. If you do not want to allow underscores in the output and want them to be converted as a separator, use Str::isStrictKebab().

Str::isLower()

The isLower method determines if the given string is entirely lowercase.

Str::isPascal()

The isPascal method checks if the given string is already in PascalCase. Str::pascal() is undocumented on laravel.com, but present in the framework source since Laravel 12. It is just an alias to Str::studly(). Rather than call Str::pascal() itself — which doesn't exist at all before Laravel 12 — isPascal calls isStudly(), so it behaves identically, including the second $normalize argument, and works across this package's full supported range.

Note: $normalize was only added to Str::studly() (and therefore isStudly()/isPascal()) in illuminate/support v13.12.0. See the note on isStudly() — the same runtime guard applies here since isPascal just calls isStudly under the hood.

Str::isPureKebab()

The isPureKebab method determines if the given string is already in kebab-case, using Str::isKebab(), it rejects the wrong separator character (e.g. underscores). Repeated dashes are accepted by default; pass a $consecutiveDashes limit to cap how many are allowed.

Str::isPureSnake()

The isPureSnake method determines if the given string is already in snake_case, using Str::isSnake(), it rejects the wrong separator character (e.g. dashes). Repeated underscores are accepted by default; pass a $consecutiveUnderscores limit to cap how many are allowed.

Str::isSlug()

The isSlug method determines if the given string is already a valid slug. It mirrors Str::slug()'s full signature — $charReplacement (separator), $language, and $dictionary — so a check can be run under the same options you'd slugify with.

$language can meaningfully flip the result, since it controls whether accented letters get transliterated to ASCII before the slug check runs:

Note: $dictionary is accepted and forwarded for signature completeness, but it can't change the boolean result in practice — its keys (like @) never survive Str::slug() either way, whether expanded via the dictionary or simply stripped by an empty one, so no input is a valid slug under one dictionary but not another.

Str::isSnake()

The isSnake method determines if the given string is already in snake_case.

Note: Str::snake() only inserts an underscore at case-boundary transitions — it never validates or collapses the separators already in the string. That means Str::isSnake('a-snakelike-string') and Str::isSnake('a__snakelike__string') both return true, even though neither looks like clean snake_case. If you do not want to allow dashes in the output and want them to be converted as a separator, use Str::isStrictSnake().

isSnake also accepts a second $delimiter argument, mirroring Str::snake()'s own $delimiter argument:

Note: unlike $language on isSlug, $delimiter is accepted for signature completeness but can't change the boolean result — Str::snake() only ever inserts a delimiter at a case boundary, so a string with no case boundary at all is a fixed point for every delimiter, and a string that does have a case boundary can never match itself for any delimiter (the result is always lowercased and always has something inserted). It's forwarded purely so the two signatures stay in sync.

Str::isStrictKebab()

The isStrictKebab method determines if the given string is already in kebab-case, using Str::isPureKebab(), it always collapses repeated separators, so there's exactly one valid spelling for a given name — useful when generating a canonical machine key.

Str::isStrictSnake()

The isStrictSnake method determines if the given string is already in snake_case, using Str::isPureSnake(), it always collapses repeated separators, so there's exactly one valid spelling for a given name — useful when generating a canonical machine key.

Str::isStudly()

The isStudly method determines if the given string is already in StudlyCase.

isStudly also accepts a second $normalize argument, mirroring Str::studly()'s own $normalize argument. When enabled, a standalone all-caps "word" (an acronym) is lowercased before comparing, so 'CBOR' no longer matches itself — only its normalized form, 'Cbor', does:

Note: $normalize was only added to Str::studly() in a recent illuminate/support release. isStudly() checks at runtime whether the installed version supports it (via reflection) and throws a RuntimeException if $normalize is requested but unsupported, instead of silently comparing against the un-normalized result — PHP doesn't error on unknown trailing arguments, it just drops them, which would otherwise produce a quietly wrong answer.

Str::isTitle()

The isTitle method determines if the given string is already in Title Case.

Str::isUpper()

The isUpper method determines if the given string is entirely uppercase.

Str::pureKebab()

The pureKebab method converts the given string to kebab-case, accepting dashes and underscores as valid input separators. Unlike Str::kebab(), it converts underscores (not just case-boundary transitions), and it groups consecutive uppercase letters (acronyms) into a single word instead of splitting every capital letter — see laravel/framework#47005.

Every individual non-alphanumeric character becomes its own dash, so repeated separators are preserved by default:

Pass $consecutiveDashes to cap how many consecutive dashes are allowed in the result (default 0 is unlimited):

If you want exactly one dash between words regardless of input, use Str::strictKebab() instead.

Str::pureSnake()

The pureSnake method converts the given string to snake_case, accepting underscores and dashes as valid input separators. Unlike Str::snake(), it converts dashes (not just case-boundary transitions), and it groups consecutive uppercase letters (acronyms) into a single word instead of splitting every capital letter — see laravel/framework#47005.

Every individual non-alphanumeric character becomes its own underscore, so repeated separators are preserved by default:

Pass $consecutiveUnderscores to cap how many consecutive underscores are allowed in the result (default 0 is unlimited):

If you want exactly one underscore between words regardless of input, use Str::strictSnake() instead.

Str::strictKebab()

The strictKebab method converts the given string to kebab-case with exactly one canonical spelling for a given name — it's a thin wrapper around Str::pureKebab() with $consecutiveDashes locked to 1, so every run of separator characters always collapses down to a single dash. Useful for generating machine keys, where 'a-kebab' and 'a--kebab' should resolve to the same value.

Str::strictSnake()

The strictSnake method converts the given string to snake_case with exactly one canonical spelling for a given name — it's a thin wrapper around Str::pureSnake() with $consecutiveUnderscores locked to 1, so every run of separator characters always collapses down to a single underscore. Useful for generating machine keys, where 'a_snake' and 'a__snake' should resolve to the same value.


All versions of laravel-str with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0|^12.0|^13.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 coyote6/laravel-str contains the following files

Loading the files please wait ...