Laravel7 comes with a new Stringable class, which is useful in so many cool ways.

Previously, we’re familiar with Laravel’s existing Illuminate\Support\Str class, which provides a variety of helpful string manipulation functions but now Laravel7 offers a more object-oriented, fluent string manipulation library built on top of these functions.

We can still use the Laravel’s Str class, and modify whatever string we want to, likeso,

return (string) Str::of('  Laravel 6.x is Awesome ')
                    ->replace('6.x', '7.x')

Let’s take a look at another example.

return (string) Str::of('Hello world')


                    ->start('Devpeel ')


For more information on the methods available via fluent string manipulation, please consult its full documentation.

You may also Like