Download the PHP package rdcstarr/laravel-placeholders without Composer
On this page you can find all versions of the php package rdcstarr/laravel-placeholders. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rdcstarr/laravel-placeholders
More information about rdcstarr/laravel-placeholders
Files in rdcstarr/laravel-placeholders
Package laravel-placeholders
Short Description Laravel Placeholders
License MIT
Homepage https://github.com/rdcstarr/laravel-placeholders
Informations about the package laravel-placeholders
Laravel Placeholders
A powerful Laravel package for managing dynamic placeholders in your strings with support for multiple transformations, date/time helpers, and custom values.
Features
- 🔄 Case Transformations: Automatic uppercase, lowercase, and title case support
- 📅 Date & Time Placeholders: Built-in support for dates, times, and timestamps
- 🎨 Custom Placeholders: Define your own placeholders globally or per-usage
- 🔒 Auto-Protection: Values containing {{}} are automatically protected
- ⚡ Closure Support: Use closures for advanced placeholder transformations
- 🎯 Stringable Objects: Handle custom objects (Money, Date, etc.) seamlessly
- 🌐 Laravel Integration: Inspired by Laravel's Translator for familiar patterns
Installation
You can install the package via composer:
Automatic Installation (Recommended)
Run the install command to publish and run the migrations:
Manual Installation
Alternatively, you can install manually:
- Publish the config file:
Usage
Basic Usage
Case Transformations
The package supports automatic case transformations:
Available Formats
{{key}}- exact value (lowercase){{Key}}- first letter uppercase{{KEY}}- all uppercase
Default Placeholders
The package provides built-in date, time, and application placeholders:
Available Default Placeholders
Date:
{{year}}- 2025{{month}}- 11{{day}}- 26{{date}}- 2025-11-26
Time:
{{hour}}- 14{{minute}}- 30{{time}}- 14:30{{datetime}}- 2025-11-26 14:30:00
Application:
{{app_name}}- Your app name{{app_url}}- Your app URL
Custom Placeholders
Using Config
Define placeholders in your config/placeholders.php:
Using Helper Functions
Using the Facade
Closure Support
Use closures for advanced transformations with <tag>content</tag> syntax:
Stringable Objects
Handle custom objects seamlessly by registering handlers:
Auto-Protection
Values containing {{}} are automatically protected from being interpreted as placeholders:
Managing Custom Placeholders
Advanced Examples
Email Template
Dynamic Content
API Response Messages
API Reference
Helper Functions
placeholders(string $text, array $placeholders = []): string- Parse and replace placeholdersset_placeholder(string|array $key, mixed $value = ''): void- Add custom placeholder(s)stringable_placeholder(string $class, callable $handler): void- Register object handler
Facade Methods
Parsing:
Placeholders::parse(string $text, array $placeholders = []): string
Custom Placeholders:
Placeholders::setCustomPlaceholders(array $placeholders): voidPlaceholders::addCustomPlaceholder(string $key, mixed $value): voidPlaceholders::clearCustomPlaceholders(): voidPlaceholders::getCustomPlaceholders(): array
Stringable Handlers:
Placeholders::stringable(string $class, callable $handler): voidPlaceholders::getStringableHandlers(): arrayPlaceholders::clearStringableHandlers(): void
Testing
📖 Resources
- Changelog for more information on what has changed recently. ✍️
👥 Credits
- Rdcstarr 🙌
📜 License
- License for more information. ⚖️
laravel-placeholders
All versions of laravel-placeholders with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0