PHPackages                             swisnl/laravel-head - 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. swisnl/laravel-head

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

swisnl/laravel-head
===================

Customize and automate head section of your layouts for Laravel

1.2.2(3y ago)38.9k1MITPHPPHP &gt;=7.0

Since Feb 18Pushed 3y ago9 watchersCompare

[ Source](https://github.com/swisnl/laravel-head)[ Packagist](https://packagist.org/packages/swisnl/laravel-head)[ RSS](/packages/swisnl-laravel-head/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (1)Versions (10)Used By (1)

laravel-head
============

[](#laravel-head)

🚨 **THIS PACKAGE HAS BEEN DEPRECATED** 🚨

This package is outdated and rarely used, so that's why we have chosen to deprecate it. Feel free to fork our code and maintain your own copy or use one of the many alternatives.

This package automate and facilitate management of the `` section for your HTML5 layouts with Laravel 4. It provides utilities for:

- Meta tags.
- Link tags.
- Stylesheets.
- Scripts.
- Charset, favicon, title and description tags.
- Search engines.
- Responsive design.
- Internet Explorer compatibility.
- Facebook's Open Graph protocol.
- Twitter Card.
- Google's Universal Analytics.

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

[](#installation)

Require this package in your composer.json and run composer update:

```
"gwnobots/laravel-head": "dev-master"

```

After updating composer, add the ServiceProvider to the providers array in app/config/app.php:

```
'Gwnobots\LaravelHead\LaravelHeadServiceProvider',

```

You need to publish the config of this package:

```
$ php artisan config:publish gwnobots/laravel-head

```

You do not need to add an Alias in app/config/app.php, as it is already registered within the ServiceProvider (see posts from [Philip Brown](http://culttt.com/2013/06/24/creating-a-laravel-4-package/) and [Chris Fidao](http://fideloper.com/create-facade-laravel-4)).

Usage
-----

[](#usage)

You can see a summary of all available methods in the [cheatsheet](https://github.com/gwnobots/laravel-head/blob/master/CHEATSHEET.md).

#### Rendering

[](#rendering)

To display all custom tags in the `` section, simply add in your layout:

```

// or with a blade layout

	{{ Head::render() }}

```

#### Basic settings

[](#basic-settings)

In package's config.php, you can set some default values like charset, sitename, description, favicon... (see comments in config.php for more explanations). These settings will be used if you don't override them for current requests with special methods (in your Routes or Controllers):

```
// define encoding for  tag
Head::setCharset('charset');

// define a title for  tag
Head::setTitle('title');

// de|activate the addition of default sitename to title
Head::noSitename();
Head::doSitename();

// define description for  tag
Head::setDescription('description');

// define a favicon for  tags (relative to public path, without extension)
Head::setFavicon('favicon');

```

You can also remove a tag by filling it with blank, for example:

```
Head::setFavicon('');

```

#### Multiple layouts

[](#multiple-layouts)

###### Settings

[](#settings)

You can manage different settings for the `` section with as many layouts as you need in package's config.php. You can override one ore several settings by adding an array at the end of the config file (see also comments in config.php), like:

```
'mylayout' => array(
    'charset' => 'ISO-8859-1',
    'twitter' => array(
        'image' => 'an-image.jpg',
    ),
),

```

Here you would override default values only for meta charset and twitter card image for the layout called 'mylayout'. Default values will be used for other settings.

You should also respect path structure:

```
'layouts' => array(
    'custom' => array(
        'charset' => 'ISO-8859-1',
    ),
),

```

In this example, you will override meta charset default value for a layout named 'custom' in the `app/views/layouts` directory.

###### Register a custom layout

[](#register-a-custom-layout)

To make use of custom settings, you need to tell your app that you are using a specific layout which may call other settings than just default ones.

In your Controller or Blade layout, call:

```
Head::setLayout('mycustomlayout');

```

An easy way to automatically manage custom layouts with Laravel's utilities is to add a constructor in BaseController.php like:

```
