1. Go to this page and download the library: Download coyote6/laravel-str library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coyote6 / laravel-str example snippets
use Illuminate\Support\Str;
$converted = Str::dot('User - View All');
// user.view.all
use Illuminate\Support\Str;
Str::isPascal('APascalOrStudlyLikeString');
// true
Str::isPascal('A Pascal Or Studly-like String');
// false
Str::isPascal('CBOR', true);
// false - normalize would rewrite it to 'Cbor' first
use Illuminate\Support\Str;
Str::isPureKebab('a-kebab-like-string');
// true
Str::isPureKebab('a_kebab_like_string');
// false
Str::isPureKebab('a--kebab--like--string');
// true - repeated dashes are fine by default
Str::isPureKebab('a--kebab--like--string', 1);
// false - exceeds the 1-consecutive-dash limit
use Illuminate\Support\Str;
Str::isPureSnake('a_snakelike_string');
// true
Str::isPureSnake('a-snakelike-string');
// false
Str::isPureSnake('a__snakelike__string');
// true - repeated underscores are fine by default
Str::isPureSnake('a__snakelike__string', 1);
// false - exceeds the 1-consecutive-underscore limit
Str::isSlug('café');
// false - 'en' (the default) transliterates é to e, so 'café' no longer matches itself
Str::isSlug('café', '-', null);
// true - transliteration disabled, so the accented letter passes through unchanged
use Illuminate\Support\Str;
Str::isSnake('a_snakelike_string');
// true
Str::isSnake('A Snake-like String');
// false
Str::isSnake('a-snake-case', '-');
// true
use Illuminate\Support\Str;
Str::isStrictKebab('a-kebab-like-string');
// true
Str::isStrictKebab('a--kebab--like--string');
// false
use Illuminate\Support\Str;
Str::isStrictSnake('a_snakelike_string');
// true
Str::isStrictSnake('a__snakelike__string');
// false
use Illuminate\Support\Str;
Str::isStudly('AStudlyLikeString');
// true
Str::isStudly('A Studly-like String');
// false
Str::isStudly('CBOR');
// true - acronyms are left alone by default
Str::isStudly('CBOR', true);
// false - normalize would rewrite it to 'Cbor' first
Str::isStudly('Cbor', true);
// true - already in the normalized shape
use Illuminate\Support\Str;
Str::isTitle('A Title For Your Article');
// true
Str::isTitle('A-Title-for-Your-Article');
// false
use Illuminate\Support\Str;
Str::pureKebab('my_example_text');
// my-example-text
Str::pureKebab('my_exampleCombined_text');
// my-example-combined-text
Str::pureKebab('A - Kebab');
// a---kebab - each of the 3 separator characters (space, dash, space) converts on its own
Str::kebab('my_example_text'); // for comparison
// my_example_text (Str::kebab() leaves this untouched)
Str::pureKebab('A - Kebab', 2);
// a--kebab
use Illuminate\Support\Str;
Str::pureSnake('my-example-text');
// my_example_text
Str::pureSnake('LARAVELFramework');
// laravel_framework
Str::pureSnake('a - snake');
// a___snake - each of the 3 separator characters (space, dash, space) converts on its own
Str::snake('LARAVELFramework'); // for comparison
// l_a_r_a_v_e_l_framework (Str::snake() splits every capital letter)
Str::pureSnake('a - snake', 2);
// a__snake
use Illuminate\Support\Str;
Str::strictKebab('my_example_text');
// my-example-text
Str::strictKebab('A - Kebab');
// a-kebab
Str::pureKebab('A - Kebab'); // for comparison
// a---kebab (pureKebab() preserves each separator character)
use Illuminate\Support\Str;
Str::strictSnake('my-example-text');
// my_example_text
Str::strictSnake('a - snake');
// a_snake
Str::pureSnake('a - snake'); // for comparison
// a___snake (pureSnake() preserves each separator character)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.