, (*1)
Titleasy - Build titles like a charm.
This package is an HTML title generator for Laravel 4., (*2)
Installation
Edit composer.json
file to require this package., (*3)
"require": {
...
"diego1araujo/titleasy": "dev-master"
}
Next, run the composer update command:, (*4)
composer update
Open up app/config/app.php
, (*5)
Find the providers
key and add a new item to the array, (*6)
'Diego1araujo\Titleasy\ServiceProvider',
Find the aliases
key and add a new item to the array, (*7)
'Title' => 'Diego1araujo\Titleasy\Facade',
Methods
put - add titles. return: void
last - retrieve last title added. return: string
get - build the title. return: string. there are 3 params:
- site name
- delimiter (default: -)
- reverse mode (default: false)
Usage
Starting, (*8)
Title::get('My Website') // Output: My Website
Adding a title, (*9)
Title::put('Users Page')
Title::get('My Website') // Output: My Website - Users Page
Changing the delimiter (Set a second parameter on get), (*10)
Title::put('Users Page')
Title::get('My Website', '|') // Output: My Website | Users Page
Switching to reverse order (Set a third parameter on get as TRUE), (*11)
Title::put('Users Page')
Title::get('My Website', '|', TRUE) // Output: Users Page | My Website
Multiple titles, (*12)
Title::put('Users Page')
Title::put('Editing')
// or just:
Title::put('Users Page', 'Editing')
Retrieving the last title added, (*13)
Title::last()
Out of Laravel
Require via composer, (*14)
composer require diego1araujo/titleasy
When asked for a version, choose:, (*15)
dev-master
Create a index.php like:, (*16)
<?php
require_once 'vendor/autoload.php';
use Diego1araujo\Titleasy\Titleasy as Title;
Title::put('Users Page');
echo Title::get('My Website');
NOTE: This job was based on mywizz's library. Credits goes to him, also., (*17)