PHP code example of tylercd100 / laravel-placeholders

1. Go to this page and download the library: Download tylercd100/laravel-placeholders library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tylercd100 / laravel-placeholders example snippets


Tylercd100\Placeholders\ServiceProvider::class

"Placeholders" => Tylercd100\Placeholders\Facades\Placeholders::class,

use Placeholders;

// Basic
Placeholders::parse("I like [fruit]s and [veg]s", [
	'fruit' => 'orange',
	'veg' => 'cucumber'
]); //I like oranges and cucumbers

// Globally
Placeholders::set("fruit", "apple");
Placeholders::set("veg", "carrot");
Placeholders::parse("I like [fruit]s and [veg]s"); // I like apples and carrots

// Change the style
Placeholders::setStyle("{{", "}}");
Placeholders::parse("I like {{fruit}}s and {{veg}}s", [
	'fruit' => 'lemon',
	'veg' => 'string bean'
]); //I like lemons and string beans

// Throw an error if one is missed
Placeholders::setThorough(true) // This is the default
Placeholders::parse("I like [fruit]s and [veg]s", [
	'fruit' => 'orange',
]); //Throws an Exception: Could not find a replacement for [veg]
bash
php artisan vendor:publish --provider="Tylercd100\Placeholders\ServiceProvider"