koenhendriks/
laravel-str-acronym
g4t.io

Generate String Acronyms with this Laravel Macro

17 views 43 stars by Paul Redmond

A package to be able to generate acronyms from strings in Laravel projects using the Str helper and supports the Stringable class.

README from koenhendriks/laravel-str-acronym Open on GitHub →

social.png

Installation

You can install the package using Composer:

composer require koenhendriks/laravel-str-acronym

After installing the package Laravel should automatically discover the package.

If you want you can register the service provider in your Laravel application manually. You can do this by adding the service provider to the providers array in your config/app.php file:

'providers' => [
    KoenHendriks\StrAcronym\StrServiceProvider::class,
],

Once you've registered the service provider, you can start using the acronym macro in your Laravel application.

Usage

To generate an acronym from a string, you can call the acronym method on the Str helper:

use Illuminate\Support\Str;

$acronym = Str::acronym('Hello World'); // Returns 'HW'

If you prefer to use the Fluent Strings, you can call the acronym method on a Stringable object:

use Illuminate\Support\Str;

$acronym = Str::of('hello world')->headline()->acronym(); // Returns 'HW'

You can also provide a delimiter string as an optional parameter to separate the acronym letters:

use Illuminate\Support\Str;

$acronym = Str::acronym('Hello World', '.'); // Returns 'H.W.'
$acronym = Str::of('hello world')->headline()->acronym(); // Returns 'H.W.'

Testing

This package is using PhpUnit to unit test the macros. A simple alias has been created with composer to run the tests.

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

This package originates from this Pull Request on the Laravel Framework

Contributors

License

This package is licensed under the MIT License. See the LICENSE file for more information.

Contributing

If you find any issues with the package or have suggestions for improvements, feel free to open an issue or pull request on the GitHub repository.

More from the ecosystem

durable-workflow/
workflow
g4t.io
9 1,292

Durable Workflow: Long-Running Workflows for Laravel

Embedded durable workflow runtime and orchestration engine for Laravel applications.

durable-workflow/workflow via Laravel News
packstub/
session-replay
g4t.io
14 52

Session Replay for Laravel: Self-Hosted Browser Recordings

Session replay for Laravel: record what a person did in the browser with rrweb, keep the recording on your own disk and database, and watch it behind a gate you define — masked inputs by default, errors, failed Livewire requests and web vitals marked on the timeline, a link to the replay in every log line. packstub/filament-session-replay adds the sessions to a Filament panel.

packstub/session-replay via Laravel News
cyberwizard-dev/
schedule-catchup
g4t.io
17

Replay Missed Laravel Scheduled Tasks With Schedule Catchup

Schedule Catchup replays missed Laravel scheduled tasks after downtime, with opt-in recovery, bounded retries, and access to the original scheduled date.

cyberwizard-dev/schedule-catchup via Laravel News