2017 © Pedro Peláez
 

library laravel-placeholders

Find and replace placeholders in a string

image

tylercd100/laravel-placeholders

Find and replace placeholders in a string

  • Wednesday, March 1, 2017
  • by tylercd100
  • Repository
  • 1 Watchers
  • 3 Stars
  • 5,486 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 24 % Grown

The README.md

Find and Replace placeholder strings in Laravel 5

Latest Version Software License Build Status Scrutinizer Code Quality Code Coverage Dependency Status Total Downloads, (*1)

Installation

Install via composer - In the terminal:, (*2)

composer require tylercd100/laravel-placeholders

Now add the following to the providers array in your config/app.php, (*3)

Tylercd100\Placeholders\ServiceProvider::class

and this to the aliases array in config/app.php, (*4)

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

Then you will need to run these commands in the terminal in order to copy the config file, (*5)

php artisan vendor:publish --provider="Tylercd100\Placeholders\ServiceProvider"

Usage

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

Style

// 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

Errors

// 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]

The Versions

01/03 2017

dev-master

9999999-dev https://github.com/tylercd100/laravel-placeholders

Find and replace placeholders in a string

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tyler Arbon

laravel placeholders tylercd100

01/03 2017

1.0.0

1.0.0.0 https://github.com/tylercd100/laravel-placeholders

Find and replace placeholders in a string

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tyler Arbon

laravel placeholders tylercd100