diff --git a/README.md b/README.md index 1595d80..52383f6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/SEO-Helper/re * Easy setup & configuration. * Well documented & IDE Friendly. * Well tested with maximum code quality. - * Laravel 5.1 supported. + * Laravel `5.0 | 5.1 | 5.2` are supported. * Made with :heart: & :coffee:. ## Table of contents @@ -38,16 +38,9 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/SEO-Helper/re 5. [API](_docs/5-API.md) 6. [Extras](_docs/6-Extras.md) -## DONE +## TODO - - [x] Framework agnostic package. - - [x] Open Graph supported. - - [x] Twitter Cards supported. - - [x] Webmaster tools supported. - - [x] Google Analytics supported. - - [x] Laravel 5.2 supported. - - [x] Laravel 5.1 supported. - - [x] Laravel 5.0 supported. + - [ ] Laravel 5.3 support. ## Contribution diff --git a/_docs/0-Home.md b/_docs/0-Home.md index c52dceb..92fddbb 100644 --- a/_docs/0-Home.md +++ b/_docs/0-Home.md @@ -1,12 +1,17 @@ # SEO Helper -SEO Helper is a package for Laravel 5 that provides tools and helpers for SEO. +SEO Helper is a package that provides tools and helpers for SEO (Search Engine Optimization). ### Features + * Framework agnostic package. + * Open Graph & Twitter Cards are supported. + * Webmaster tools site verifier tags are supported. + * Google Analytics tracking is supported. * Easy setup & configuration. * Well documented & IDE Friendly. * Well tested with maximum code quality. + * Laravel `5.0 | 5.1 | 5.2` are supported. * Made with :heart: & :coffee:. ## Table of contents diff --git a/_docs/1-Requirements.md b/_docs/1-Requirements.md index 970a4c6..209a5a9 100644 --- a/_docs/1-Requirements.md +++ b/_docs/1-Requirements.md @@ -1,5 +1,15 @@ # 1. Requirements +## Table of contents + +0. [Home](0-Home.md) +1. [Requirements](1-Requirements.md) +2. [Installation and Setup](2-Installation-and-Setup.md) +3. [Configuration](3-Configuration.md) +4. [Usage](4-Usage.md) +5. [API](5-API.md) +6. [Extras](6-Extras.md) + ## Server Requirements The SEO Helper package has a few system requirements: diff --git a/_docs/2-Installation-and-Setup.md b/_docs/2-Installation-and-Setup.md index 69b215b..940006b 100644 --- a/_docs/2-Installation-and-Setup.md +++ b/_docs/2-Installation-and-Setup.md @@ -1,5 +1,15 @@ # 2. Installation +## Table of contents + +0. [Home](0-Home.md) +1. [Requirements](1-Requirements.md) +2. [Installation and Setup](2-Installation-and-Setup.md) +3. [Configuration](3-Configuration.md) +4. [Usage](4-Usage.md) +5. [API](5-API.md) +6. [Extras](6-Extras.md) + ## Composer You can install this package via [Composer](http://getcomposer.org/) by running this command: `composer require arcanedev/seo-helper`. @@ -31,7 +41,7 @@ Once the package is installed, you can register the service provider in `config/ ], ``` -And for the Facades: +(**Optional**) And for the Facades: ```php // config/app.php diff --git a/_docs/3-Configuration.md b/_docs/3-Configuration.md index e5fa6b9..c814316 100644 --- a/_docs/3-Configuration.md +++ b/_docs/3-Configuration.md @@ -4,14 +4,21 @@ ## Table of contents -* [Title](#title) -* [Description](#description) -* [Keywords](#keywords) -* [Miscellaneous](#miscellaneous) -* [Webmaster Tools](#webmaster-tools) -* [Analytics](#analytics) -* [Open Graph](#open-graph) -* [Twitter](#twitter) +0. [Home](0-Home.md) +1. [Requirements](1-Requirements.md) +2. [Installation and Setup](2-Installation-and-Setup.md) +3. [Configuration](3-Configuration.md) + * [Title](#title) + * [Description](#description) + * [Keywords](#keywords) + * [Miscellaneous](#miscellaneous) + * [Webmaster Tools](#webmaster-tools) + * [Open Graph](#open-graph) + * [Twitter](#twitter) + * [Analytics](#analytics) +4. [Usage](4-Usage.md) +5. [API](5-API.md) +6. [Extras](6-Extras.md) After you've published the config file `config/seo-helper.php`, you can customize the settings : @@ -72,18 +79,11 @@ After you've published the config file `config/seo-helper.php`, you can customiz ], ``` -### Analytics - -```php -'analytics' => [ - 'google' => '', // UA-XXXXXXXX-X -], -``` - ### Open Graph ```php 'open-graph' => [ + 'enabled' => true, 'prefix' => 'og:', 'type' => 'website', 'title' => 'Default Open Graph title', @@ -99,12 +99,21 @@ After you've published the config file `config/seo-helper.php`, you can customiz ```php 'twitter' => [ - 'prefix' => 'twitter:', - 'card' => 'summary', - 'site' => 'Username', - 'title' => 'Default Twitter Card title', - 'metas' => [ + 'enabled' => true, + 'prefix' => 'twitter:', + 'card' => 'summary', + 'site' => 'Username', + 'title' => 'Default Twitter Card title', + 'metas' => [ // ], ], ``` + +### Analytics + +```php +'analytics' => [ + 'google' => '', // UA-XXXXXXXX-X +], +``` diff --git a/_docs/4-Usage.md b/_docs/4-Usage.md index 268cdd4..6c4be38 100644 --- a/_docs/4-Usage.md +++ b/_docs/4-Usage.md @@ -1,29 +1,36 @@ # 4. Usage -> **:warning: DISCLAIMER :** French speaker here ! Brace yourselves, omelette du fromage is coming. - ## Table of contents -1. [Entities](#1-entities) - * [Title](#title) - * [Description](#description) - * [Keywords](#keywords) - * [Miscellaneous Tags](#miscellaneous-tags) - * [Webmasters](#webmasters) - * [Analytics](#analytics) - * [Open Graph](#open-graph) - * [Twitter Card](#twitter-card) -2. [Helpers](#2-helpers) - * [Meta](#meta) -3. [Managers](#3-managers) - * [SEO Meta](#seo-meta) - * [SEO Open Graph](#seo-open-graph) - * [SEO Twitter Card](#seo-twitter-card) -4. [Laravel Usage](#4-laravel-usage) +0. [Home](0-Home.md) +1. [Requirements](1-Requirements.md) +2. [Installation and Setup](2-Installation-and-Setup.md) +3. [Configuration](3-Configuration.md) +4. [Usage](4-Usage.md) + 1. [Entities](#1-entities) + * [Title](#title) + * [Description](#description) + * [Keywords](#keywords) + * [Miscellaneous Tags](#miscellaneous-tags) + * [Webmasters](#webmasters) + * [Analytics](#analytics) + * [Open Graph](#open-graph) + * [Twitter Card](#twitter-card) + 2. [Helpers](#2-helpers) + * [Meta](#meta) + 3. [Managers](#3-managers) + * [SEO Meta](#seo-meta) + * [SEO Open Graph](#seo-open-graph) + * [SEO Twitter Card](#seo-twitter-card) + 4. [Laravel Usage](#4-laravel-usage) +5. [API](5-API.md) +6. [Extras](6-Extras.md) + +> **:warning: DISCLAIMER :** French speaker here ! Brace yourselves, omelette du fromage is coming. ## 1. Entities -All the `Entities` classes are located in `Arcanedev\SeoHelper\Entities` namespace and they implements the `Arcanedev\SeoHelper\Contracts\Renderable` interface. +All the `Entities` are located in `Arcanedev\SeoHelper\Entities` namespace and they implements the `Arcanedev\SeoHelper\Contracts\Renderable` interface. ```php render(); Your awesome title ``` -If you need to add a site name to the title: +If you need to add a site name to the title, use the `setSiteName()` method: ```php use Arcanedev\SeoHelper\Entities\Title; @@ -83,7 +90,7 @@ echo $title->render(); Your awesome title - Company name ``` -The default title separator is `-`, you can modifying it by doing this: +The default title separator is `-`, you can modifying it by calling the `setSeparator()` method like this (the order doesn't matter): ```php use Arcanedev\SeoHelper\Entities\Title; @@ -102,7 +109,7 @@ echo $title->render(); Your awesome title | Company name ``` -By the way, you can chain all these methods : +**OH WAIT !!!** You can chain all these methods: ```php use Arcanedev\SeoHelper\Entities\Title; @@ -121,7 +128,7 @@ echo $title->render(); Your awesome title | Company name ``` -You can also `make` the title object: +You can also use the `make` method to create a title object: ```php use Arcanedev\SeoHelper\Entities\Title; @@ -137,9 +144,9 @@ echo $title->render(); Your awesome title | Company name ``` -> :information_source: The **site name** and **separator** are **optionals**, you can simply do this `Title::make('Your awesome title');`. +> :information_source: The **site name** and **separator** are **optional arguments**, you can simply do this `Title::make('Your awesome title');`. -To switch the title and site name positions: +To switch the title and site name positions, use the `setFirst()` and `setLast()` methods: ```php use Arcanedev\SeoHelper\Entities\Title; @@ -158,7 +165,7 @@ echo $title->render(); To reset the title position, use `setFirst()` method. -> :information_source: You know that the title must be optimized for the SEO, Right ?? So the optimal title length is **55** characters long. +> :information_source: Keep in mind that the title must be optimized for the SEO, the optimal length is **55** characters long, so i make it as a default max lenght to render. ```php use Arcanedev\SeoHelper\Entities\Title; @@ -175,7 +182,7 @@ echo $title->render(); Lorem ipsum dolor sit amet, consectetur adipiscing elit... ``` -You can specify the maximum length by using the `setMax()` method : +You can specify your own maximum length by using the `setMax()` method : ```php use Arcanedev\SeoHelper\Entities\Title; @@ -245,7 +252,7 @@ echo $description->render(); ``` -You can also specify the maximum length by using the `setMax()` method (default max is **155**): +To specify the maximum length, use the `setMax()` method (the default max value is **155**, recommended for SEO): ```php use Arcanedev\SeoHelper\Entities\Description; @@ -282,6 +289,8 @@ echo $description->render(); ``` +> :information_source: The second argument `max` is optional. + And last but not least, the `Description` class constructor accepts an array as an argument: | Key | Type | Required | Description | @@ -357,7 +366,8 @@ $keywords = new Keywords; $keywords->set([ 'seo-helper', 'is', 'awesome', 'cool', 'easy', 'php', 'package' ]); -$keywords->add('laravel')->add('supported'); +$keywords->add('laravel'); +$keywords->add('supported'); echo $keywords->render(); ``` @@ -368,6 +378,8 @@ echo $keywords->render(); ``` +> :information_source: You can chain these methods like this `$keywords->set([...])->add('...')->add('...');`. + You can also pass an array as argument to the constructor: | Key | Type | Required | Description | @@ -1011,7 +1023,7 @@ echo $meta->render(); ``` -(Add description here...) +An other example with a different meta tag: ```php use Arcanedev\SeoHelper\Helpers\Meta; @@ -1027,7 +1039,7 @@ echo $meta; ``` -(Add description here...) +You can also create your custom meta tags: ```php use Arcanedev\SeoHelper\Helpers\Meta; @@ -1043,7 +1055,7 @@ echo $meta; ``` -You can use the `make` method to create a meta object: +You can use the static method `make` to create a meta object: ```php use Arcanedev\SeoHelper\Helpers\Meta; @@ -1065,23 +1077,89 @@ For more details, check the [Meta API](5-API.md#meta). ### SEO Meta -```php -``` +The SeoMeta class (`Arcanedev\SeoHelper\SeoMeta`) is a manager that gives you a total control to create all the generic or custom meta tags. -For more details, check the [SEO Meta API](5-API.md#seo-meta). +For more details about the available methods, check the [SEO Meta API](5-API.md#seo-meta). + +Check also the `SeoMeta` [tests for more usage examples](https://github.com/ARCANEDEV/SEO-Helper/blob/master/tests/SeoMetaTest.php). ### SEO Open Graph -```php -``` +The SeoOpenGraph class (`Arcanedev\SeoHelper\SeoOpenGraph`) is a manager that control the rendering of all the open-graph tags. + +For more details about the available methods, check the [SEO Open Graph API](5-API.md#seo-open-graph). + +Check also the `SeoOpenGraph` [tests for more usage examples](https://github.com/ARCANEDEV/SEO-Helper/blob/master/tests/SeoOpenGraphTest.php). + +### SEO Twitter + +The SeoTwitter class (`Arcanedev\SeoHelper\SeoTwitter`) is a manager that control the rendering of all the twitter card tags. + +For more details about the available methods, check the [SEO Twitter API](5-API.md#seo-twitter-card). + +Check also the `SeoTwitter` [tests for more usage examples](https://github.com/ARCANEDEV/SEO-Helper/blob/master/tests/SeoTwitterTest.php). + +### SEO Helper + +The SeoHelper class (`Arcanedev\SeoHelper\SeoHelper`) is a manager that groups and control all the other managers (`SeoMeta`, `SeoOpenGraph`, `SeoTwitter`). -For more details, check the [SEO Open Graph API](5-API.md#seo-open-graph). +For more details about the available methods, check the [SEO Helper API](5-API.md#seo-helper). -### SEO Twitter Card +Check also the `SeoHelper` [tests for more usage examples](https://github.com/ARCANEDEV/SEO-Helper/blob/master/tests/SeoHelperTest.php). + +## 4. Laravel Usage + +For the laravel users (AKA `artisans`), you can use the `seo_helper()` helper inside your blade views. + +For example, if you want to render all the tags inside your blade view: + +```blade + + {{ seo_helper()->render() }} + +``` +You can also do stuff like this (rendering the tags without the opengraph and twitter card): +```blade + + {{ seo_helper()->meta()->render() }} + +``` + +There is also a `trait` (`Arcanedev\SeoHelper\Traits\Seoable`) that you can add it inside your base controller and start managing your seo tags and stuff for each page. ```php +seo()`: -## 4. Laravel Usage +```php +seo() + ->setTitle('My awesome title') + ->setDescription('My awesome description') + ->setKeywords(['this', 'package', 'is', 'awesome']); + + return view('home'); + } +} +``` + +The `$this->seo()` method gives you the ability to change your meta tags dynamically and on the fly, you can use the `trait` in other class like Models for example, so **BE CREATIVE**. diff --git a/_docs/5-API.md b/_docs/5-API.md index dce1893..8d3288e 100644 --- a/_docs/5-API.md +++ b/_docs/5-API.md @@ -1,24 +1,33 @@ # 5. API +> **:warning: DISCLAIMER :** French speaker here ! Brace yourselves, omelette du fromage is coming. + ## Table of contents -1. [Contracts](#1-contracts) - * [Renderable](#renderable) -2. [Entities](#2-entities) - * [Title](#title) - * [Description](#description) - * [Keywords](#keywords) - * [Miscellaneous Tags](#miscellaneous-tags) - * [Webmasters](#webmasters) - * [Analytics](#analytics) - * [Open Graph](#open-graph) - * [Twitter Card](#twitter-card) -3. [Helpers](#3-helpers) - * [Meta](#meta) -3. [Managers](#3-manager) - * [SEO Meta](#seo-meta) - * [SEO Open Graph](#seo-open-graph) - * [SEO Twitter Card](#seo-twitter-card) +0. [Home](0-Home.md) +1. [Requirements](1-Requirements.md) +2. [Installation and Setup](2-Installation-and-Setup.md) +3. [Configuration](3-Configuration.md) +4. [Usage](4-Usage.md) + 1. [Contracts](#1-contracts) + * [Renderable](#renderable) + 2. [Entities](#2-entities) + * [Title](#title) + * [Description](#description) + * [Keywords](#keywords) + * [Miscellaneous Tags](#miscellaneous-tags) + * [Webmasters](#webmasters) + * [Analytics](#analytics) + * [Open Graph](#open-graph) + * [Twitter Card](#twitter-card) + 3. [Helpers](#3-helpers) + * [Meta](#meta) + 4. [Managers](#3-manager) + * [SEO Meta](#seo-meta) + * [SEO Open Graph](#seo-open-graph) + * [SEO Twitter Card](#seo-twitter-card) + 5. [API](5-API.md) + 6. [Extras](6-Extras.md) ## 1. Contracts @@ -51,7 +60,7 @@ interface Renderable ## 2. Entities -### Title +### Title ```php + */ interface TwitterCardInterface extends Renderable { + /* ------------------------------------------------------------------------------------------------ + | Constants + | ------------------------------------------------------------------------------------------------ + */ + const TYPE_APP = 'app'; + const TYPE_GALLERY = 'gallery'; + const TYPE_PHOTO = 'photo'; + const TYPE_PLAYER = 'player'; + const TYPE_PRODUCT = 'product'; + const TYPE_SUMMARY = 'summary'; + const TYPE_SUMMARY_LARGE_IMAGE = 'summary_large_image'; + /* ------------------------------------------------------------------------------------------------ | Getters & Setters | ------------------------------------------------------------------------------------------------ */ /** + * Set the card type. * * @param string $type * @@ -613,6 +641,13 @@ interface TwitterCardInterface extends Renderable */ public function addMeta($name, $content); + /** + * Get all supported card types. + * + * @return array + */ + public function types(); + /* ------------------------------------------------------------------------------------------------ | Main Functions | ------------------------------------------------------------------------------------------------ @@ -698,6 +733,12 @@ interface MetaInterface extends Renderable ```php + */ interface SeoMeta extends Renderable { /* ------------------------------------------------------------------------------------------------ @@ -707,7 +748,7 @@ interface SeoMeta extends Renderable /** * Set the Title instance. * - * @param TitleInterface $title + * @param \Arcanedev\SeoHelper\Contracts\Entities\TitleInterface $title * * @return self */ @@ -716,7 +757,7 @@ interface SeoMeta extends Renderable /** * Set the Description instance. * - * @param DescriptionInterface $description + * @param \Arcanedev\SeoHelper\Contracts\Entities\DescriptionInterface $description * * @return self */ @@ -725,7 +766,7 @@ interface SeoMeta extends Renderable /** * Set the Keywords instance. * - * @param KeywordsInterface $keywords + * @param \Arcanedev\SeoHelper\Contracts\Entities\KeywordsInterface $keywords * * @return self */ @@ -734,7 +775,7 @@ interface SeoMeta extends Renderable /** * Set the MiscTags instance. * - * @param MiscTagsInterface $misc + * @param \Arcanedev\SeoHelper\Contracts\Entities\MiscTagsInterface $misc * * @return self */ @@ -743,7 +784,7 @@ interface SeoMeta extends Renderable /** * Set the Webmasters instance. * - * @param WebmastersInterface $webmasters + * @param \Arcanedev\SeoHelper\Contracts\Entities\WebmastersInterface $webmasters * * @return self */ diff --git a/_docs/6-Extras.md b/_docs/6-Extras.md index 5a6967b..52d4a30 100644 --- a/_docs/6-Extras.md +++ b/_docs/6-Extras.md @@ -1,5 +1,15 @@ # 6. Extras +## Table of contents + +0. [Home](0-Home.md) +1. [Requirements](1-Requirements.md) +2. [Installation and Setup](2-Installation-and-Setup.md) +3. [Configuration](3-Configuration.md) +4. [Usage](4-Usage.md) +5. [API](5-API.md) +6. [Extras](6-Extras.md) + ## Q&A : * **Q:** Where to ask questions ?