2017 © Pedro Peláez
 

library laravel-meta

A package to manage Header Meta Tags

image

eusonlito/laravel-meta

A package to manage Header Meta Tags

  • Saturday, May 19, 2018
  • by eusonlito
  • Repository
  • 7 Watchers
  • 97 Stars
  • 46,889 Installations
  • JavaScript
  • 2 Dependents
  • 0 Suggesters
  • 52 Forks
  • 7 Open issues
  • 25 Versions
  • 10 % Grown

The README.md

HTML Meta Tags management package available for Laravel >= 5 (Including 10)

Build Status Latest Stable Version Total Downloads License, (*1)

With this package you can manage header Meta Tags from Laravel controllers., (*2)

If you want a Laravel <= 4.2 compatible version, please use v4.2 branch., (*3)

Installation

Begin by installing this package through Composer., (*4)

{
    "require": {
        "eusonlito/laravel-meta": "3.1.*"
    }
}

Laravel installation


// config/app.php 'providers' => [ '...', Eusonlito\LaravelMeta\MetaServiceProvider::class ]; 'aliases' => [ '...', 'Meta' => Eusonlito\LaravelMeta\Facade::class, ];

Now you have a Meta facade available., (*5)

Publish the config file:, (*6)

php artisan vendor:publish --provider="Eusonlito\LaravelMeta\MetaServiceProvider"

app/Http/Controllers/Controller.php


    
        

        
        

        {!! Meta::get('title') !!}

        {!! Meta::tag('robots') !!}

        {!! Meta::tag('site_name', 'My site') !!}
        {!! Meta::tag('url', Request::url()); !!}
        {!! Meta::tag('locale', 'en_EN') !!}

        {!! Meta::tag('title') !!}
        {!! Meta::tag('description') !!}

        {!! Meta::tag('canonical') !!}

        {{-- Print custom section images and a default image after that --}}
        {!! Meta::tag('image', asset('images/default-logo.png')) !!}
    

    
        ...
    

``` Or you can use Blade directives: ```php , (*7)

{!! Meta::get('title') !!}

@meta('robots') @meta('site_name', 'My site') @meta('url', Request::url()) @meta('locale', 'en_EN') @meta('title') @meta('description') @meta('canonical') {{-- Print custom section images and a default image after that --}} @meta('image', asset('images/default-logo.png')) {{-- Or use @metas to get all tags at once --}} @metas , (*8)

...

``` ### MetaProduct / og:product This will allow you to add product data to your meta data. See [Open Graph product object](https://developers.facebook.com/docs/payments/product/) ```php // resources/views/html.php , (*9)

... {!! Meta::tag('type') !!} // this is needed for Meta Product to change the og:type to og:product {!! Meta::tag('product') !!} ``` Add your product data from your controller ```php 100, 'currency' => 'EUR', ]); # if multiple currencies just add more product metas Meta::set('product', [ 'price' => 100, 'currency' => 'USD', ]); return view('index'); } } ``` ### Config ```php return [ /* |-------------------------------------------------------------------------- | Limit title meta tag length |-------------------------------------------------------------------------- | | To best SEO implementation, limit tags. | */ 'title_limit' => 70, /* |-------------------------------------------------------------------------- | Limit description meta tag length |-------------------------------------------------------------------------- | | To best SEO implementation, limit tags. | */ 'description_limit' => 200, /* |-------------------------------------------------------------------------- | Limit image meta tag quantity |-------------------------------------------------------------------------- | | To best SEO implementation, limit tags. | */ 'image_limit' => 5, /* |-------------------------------------------------------------------------- | Available Tag formats |-------------------------------------------------------------------------- | | A list of tags formats to print with each definition | */ 'tags' => ['Tag', 'MetaName', 'MetaProperty', 'MetaProduct', 'TwitterCard'], ]; ``` ### Using Meta outside Laravel #### Controller ```php require __DIR__.'/vendor/autoload.php'; // Check default settings $config = require __DIR__.'/src/config/config.php'; $Meta = new Eusonlito\LaravelMeta\Meta($config); # Default title $Meta->title('This is default page title to complete section title'); # Default robots $Meta->set('robots', 'index,follow'); # Section description $Meta->set('title', 'This is a detail page'); $Meta->set('description', 'All about this detail page'); $Meta->set('image', '/images/detail-logo.png'); # Canonical URL $Meta->set('canonical', 'http://example.com'); ``` #### Template ```php , (*10)

= $Meta->get('title'); ?></title> = $Meta->tag('robots'); ?> = $Meta->tag('site_name', 'My site'); ?> = $Meta->tag('url', getenv('REQUEST_URI')); ?> = $Meta->tag('locale', 'en_EN'); ?> = $Meta->tag('title'); ?> = $Meta->tag('description'); ?> = $Meta->tag('canonical'); ?> # Print custom section image and a default image after that = $Meta->tag('image', '/images/default-logo.png'); ?> <h4 id="updates-from-2">Updates from 2.*</h4> <ul> <li> <code>Meta::meta('title', 'Section Title')</code> > <code>Meta::set('title', 'Section Title')</code> </li> <li> <code>Meta::meta('title')</code> > <code>Meta::get('title')</code> </li> <li> <code>Meta::tagMetaName('title')</code> > <code>Meta::tag('title')</code> </li> <li> <code>Meta::tagMetaProperty('title')</code> > <code>Meta::tag('title')</code> </li> </ul>

The Versions

19/05 2018

dev-master

9999999-dev

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

19/05 2018

v3.1.6

3.1.6.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

19/05 2018

dev-develop

dev-develop

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

05/05 2018

v3.1.5

3.1.5.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

05/05 2018

v3.1.4

3.1.4.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

05/05 2018

v3.1.3

3.1.3.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

02/10 2017

v3.1.2

3.1.2.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

10/04 2017

v3.1.1

3.1.1.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

10/04 2017

v3.1.0

3.1.0.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

26/05 2016

v3.0.0

3.0.0.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

30/03 2016

v2.0.8.2

2.0.8.2

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

16/12 2015

4.2.x-dev

4.2.9999999.9999999-dev

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

laravel tags meta head

09/12 2015

v2.0.8.1

2.0.8.1

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

22/08 2015

v2.0.8

2.0.8.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

22/08 2015

v2.0.7.1

2.0.7.1

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

22/08 2015

v2.0.7

2.0.7.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

06/07 2015

v2.0.6

2.0.6.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

06/07 2015

v2.0.5

2.0.5.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

10/06 2015

v2.0.4

2.0.4.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

10/06 2015

v2.0.3

2.0.3.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

18/05 2015

v2.0.2

2.0.2.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

18/05 2015

v2.0.1

2.0.1.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

18/05 2015

v2.0.0

2.0.0.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

26/03 2015

v1.0.1

1.0.1.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

laravel tags meta head

14/08 2014

v1.0

1.0.0.0

A package to manage Header Meta Tags

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

laravel tags meta head