Skip to content

Latest commit

 

History

History
193 lines (131 loc) · 4.07 KB

README.md

File metadata and controls

193 lines (131 loc) · 4.07 KB

Laravel SEO

Latest Stable Version Total Downloads License Code Quality Build Status

A SEO package made for maximum customization and flexibility.

Installation

composer require romanzipp/laravel-seo

Or add romanzipp/laravel-seo to your composer.json

"romanzipp/laravel-seo": "^1.0.0"

Run composer install to pull the latest version.

If you use Laravel 5.5+ you are already done, otherwise continue:

Add Service Provider to your app.php configuration file:

romanzipp\Seo\Providers\SeoServiceProvider::class,

Configuration

Copy configuration to config folder:

$ php artisan vendor:publish --provider="romanzipp\Seo\Providers\SeoServiceProvider"

Usage

Instantiation

use romanzipp\Seo\Facades\Seo;
use romanzipp\Seo\Services\SeoService;

class IndexController
{
    public function index(Request $request, SeoService $seo)
    {
        $seo = seo();

        $seo = app(SeoService::class);

        $seo = Seo::make();
    }
}

Examples

Title

use romanzipp\Seo\Structs\Title;

seo()->add(Title::make()->body('romanzipp'));
seo()->title('romanzipp');

... both compile to ...

<title>romanzipp</title>

Charset

use romanzipp\Seo\Structs\Meta\Charset;

seo()->add(new Charset);
use romanzipp\Seo\Structs\Meta\Charset;

seo()->add(Charset::make());
use romanzipp\Seo\Structs\Meta\Charset;

seo()->add(Charset::make()->charset('utf-8'));

... all compile to ...

<meta charset="utf-8" />

Twitter

seo()->twitter('card', 'summary');
use romanzipp\Seo\Structs\Meta\Twitter;

seo()->add(Twitter::make()->name('card')->content('summary'));

... both compile to ...

<meta name="twitter:card" content="summary" />

Open Graph

seo()->twitter('site_name', 'romanzipp');
use romanzipp\Seo\Structs\Meta\OpenGraph;

seo()->add(OpenGraph::make()->name('site_name')->content('romanzipp'));

... both compile to ...

<meta name="og:site_name" content="romanzipp" />

For more information see the Structs Documentation.

Render

{{ seo()->render() }}

Schema.org Integration

This package features a basic integration for Spaties Schema.org package to generate ld+json scripts. Added Schema types render with the packages structs.

use Spatie\SchemaOrg\Schema;

seo()->addSchema(
    Schema::localBusiness()->name('Spatie')
);
use Spatie\SchemaOrg\Schema;

seo()->setSchemes([
    Schema::localBusiness()->name('Spatie'),
    Schema::airline()->name('Spatie'),
]);

Take a look at the Schema.org package Docs.

Cheat Sheet

Code Rendered HTML
seo()->title('romanzipp') <title>romanzipp</title>
seo()->meta('author', 'romanzipp') <meta name="author" content="romanzipp" />
seo()->twitter('card', 'summary') <meta name="twitter:card" content="summary" />
seo()->og('site_name', 'romanzipp') <meta name="og:site_name" content="romanzipp" />
seo()->add(Charset::make()->charset('utf-8')) <meta charset="utf-8" />

Documentation

Documentation

Testing

./vendor/bin/phpunit