Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Laravel Str Helper: String Manipulation

Master Laravel's string helper methods for text manipulation.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Common Methods
  2. Fluent Strings
  3. Useful Methods
  4. Conditionals

Powerful string helpers:

Common Methods

php
Str::slug('Laravel Framework'); // laravel-framework
Str::title('hello world'); // Hello World
Str::camel('foo_bar'); // fooBar
Str::kebab('fooBar'); // foo-bar

Fluent Strings

php
$result = Str::of('  Laravel  ')
    ->trim()
    ->lower()
    ->slug();

Useful Methods

php
Str::limit('Long text...', 10);
Str::words('Many words here', 2);
Str::mask('secret', '*', 2); // se****
Str::uuid();

Conditionals

php
Str::contains('Laravel', 'ara'); // true
Str::startsWith('Laravel', 'Lar'); // true
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read