PHPackages                             rephlux/pagetitle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. rephlux/pagetitle

ActiveLibrary[Templating &amp; Views](/categories/templating)

rephlux/pagetitle
=================

Manage page title in Laravel views

v2.4(6y ago)1936.1k↓50%10[1 PRs](https://github.com/rephluX/laravel-pagetitle/pulls)1MITPHPPHP ^7.2

Since Aug 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/rephluX/laravel-pagetitle)[ Packagist](https://packagist.org/packages/rephlux/pagetitle)[ Docs](https://github.com/rephluX/laravel-pagetitle)[ RSS](/packages/rephlux-pagetitle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (16)Used By (1)

Manage the Page Title in Blade views
====================================

[](#manage-the-page-title-in-blade-views)

[![Build Status](https://camo.githubusercontent.com/b0d821c9bf16792d933b1c2ca38f33c65dea5b29eaa203cac030dcfa1d845889/68747470733a2f2f7472617669732d63692e6f72672f726570686c75582f6c61726176656c2d706167657469746c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rephluX/laravel-pagetitle)[![Latest Stable Version](https://camo.githubusercontent.com/cb05241855f41dd8a2cf96e627265abb01e4bef04c241d00c114fe2b1bb0179f/68747470733a2f2f706f7365722e707567782e6f72672f726570686c75782f706167657469746c652f762f737461626c652e737667)](https://packagist.org/packages/rephlux/pagetitle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6ba920da0583bd21be0b89c46e0605486e72896615dbfa64b9ce64062f3a4134/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726570686c75582f6c61726176656c2d706167657469746c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rephluX/laravel-pagetitle/?branch=master)[![License](https://camo.githubusercontent.com/ad24e94aee2b26064b233c4a144458d91b56630213d7af3ed0da35414542f4e6/68747470733a2f2f706f7365722e707567782e6f72672f726570686c75782f706167657469746c652f6c6963656e73652e737667)](https://packagist.org/packages/rephlux/pagetitle)

Often, you'll find yourself in situations, where you want to have more to control how to set a page title for your different views. Although it is possible to yield your page title in a master view it can be a hassle to deal with the format like a delimeter usage or to append/prepend a default page title.

This package simplifies the process.

Installation
------------

[](#installation)

Begin by installing this package through Composer:

```
composer require rephlux/pagetitle
```

### Laravel Users

[](#laravel-users)

If you are a Laravel user, then there is a service provider that need to add to your `config/app.php` file.

```
'providers' => [
    '...',
    Rephlux\PageTitle\PageTitleServiceProvider::class
];
```

This package also provides a facade, which you may also register in your `config/app.php` as well if you want to use the facade in your controllers and views:

```
 'aliases' => [
     '...'
     'PageTitle' => Rephlux\PageTitle\Facades\PageTitle::class,
 ]
```

> In Laravel 5.5, [service providers and aliases are automatically registered](https://laravel.com/docs/5.5/packages#package-discovery). If you're using Laravel 5.5, you can skip these steps.

Version 2.0
-----------

[](#version-20)

If you still use PHP 7.0 or 5.6 you need to use version 1.0 of this package. Version 2.0 and above is only compatible with PHP 7.1 or newer.

Version 2.0 of this package is also compatible with Laravel 5.5 and newer.

Useage
------

[](#useage)

To simple add a single page title, call the appropiate `add()` method with passing a string as a parameter:

```
public function index()
{
    \PageTitle::add('Welcome to our Homepage');

    return view('hello');
}
```

You can also make use of the global `pagetitle` helper function.

```
public function index()
{
    pagetitle('Welcome to our Homepage');

    return view('hello');
}
```

To add multiple page title parts at once just pass an array as a parameter.

```
public function index()
{
    pagetitle([
        'About us',
        'Profile'
    ]);

    return view('hello');
}
```

### Add the pagetitle to a blade view

[](#add-the-pagetitle-to-a-blade-view)

Now you can display the fully concatenated page title in your view. The best way is to use it in your master layout file.

```

    {{ pagetitle()->get() }}
    ...

```

To display the fully concatenated page title in reverse order just pass the `reverse` parameter.

```

    {{ pagetitle()->get('reverse') }}
    ...

```

The `downward` mode first concatenates all page title parts in reverse order and then appends the page name ( *if set in options* )

```

    {{ pagetitle()->get('downward') }}
    ...

```

### Defaults

[](#defaults)

If using Laravel, there are three configuration options that you'll need to worry about. First, publish the default configuration with the following command:

```
php artisan vendor:publish --provider="Rephlux\PageTitle\PageTitleServiceProvider"
```

This will add a new configuration file to: `config/pagetitle.php`.

```
