Laravel Packages

Laravel Advanced String Package

Published

Welcome to the first episode of a new "Creator Spotlight" video series where we interview Laravel developers about the things they are creating. Today we talk with Matt Stenson who created a Laravel Advanced String package that adds extra advanced string manipulation methods to the built-in Str class. This package provides extended functionality on strings, such as advanced password generation, data redaction, and more.

Available Methods

The String methods this package includes are:

advPassword

Generates a random, secure password.

public static function advPassword(
$length = 32,
$letters = true,
$numbers = true,
$symbols = true,
$spaces = false,
$upperLetters = false,
$lowerLetters = false,
$exclude = []
)

charWrap

Wraps a string at a given number of characters regardless of words.

public static function charWrap(
$string,
$length = 80
)

emailDomain

Extracts the domain part of an email address, including subdomains.

public static function emailDomain(
$string
)

readTime

Calculates the read time of a string.

public static function readTime(
$string,
$wpm = 200
)

redactCreditCard

Redacts credit card numbers in a string.

public static function redactCreditCard(
$string,
$redacted = '********',
$exclude = []
)

redactSsn

Redacts Social Security Numbers (SSN) in a string.

public static function redactSsn(
$string,
$redacted = '********',
$dashes = true,
$noDashes = true
)

splitName

Splits a full name into first name, middle name (if present), and last name, removing any prefixes and suffixes. This method can handle both "Firstname Lastname" and "Lastname, Firstname" formats.

public static function splitName(
$name
)

More information

For more info check out the Github Repo for installation details, API docs, and more.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
Laravel Starter Kits Now Ship with Vite+ image

Laravel Starter Kits Now Ship with Vite+

Read article
Pessimistic Locking in Laravel Eloquent with refreshForUpdate() image

Pessimistic Locking in Laravel Eloquent with refreshForUpdate()

Read article
Mask Query Bindings in Laravel Exception Messages image

Mask Query Bindings in Laravel Exception Messages

Read article
whereBinary(): Case-Sensitive MySQL Queries in Laravel image

whereBinary(): Case-Sensitive MySQL Queries in Laravel

Read article
Compile PHP to Native Binaries with TypePHP image

Compile PHP to Native Binaries with TypePHP

Read article
State of Laravel 2026 Survey Is Now Open image

State of Laravel 2026 Survey Is Now Open

Read article