Download the PHP package demi/seo without Composer
On this page you can find all versions of the php package demi/seo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package seo
Short Description Library for working with SEO parameters of models
License GPL-3.0-or-later
Homepage https://github.com/demisang/yii2-seo#readme
Informations about the package seo
yii2-seo
Library for working with SEO parameters of models
How it works:
You add 2 fields to you model:
seo_urlVARCHAR: it is unique model name, example:http://example.com/post/<seo_url>.seo_metaTEXT: it is serialized array:['title' => 'Post title', 'desc' => 'Post description', 'keys' => 'Post title, other keywords...'].
This behavior help you with:
- Generate
seo_urlfrom model title considering your unique-conditions. - Internationalization for
seo_meta. - Get model view url by simple call
$model->viewUrl. (return relative url/post/my-firstand even/cat1/cat2/awesome-postis possible). - Output model seo fields(internationalized) to html:
<title>,<meta name="description">and<meta name="keywords"> - Form fields for
seo_urland allseo_metaand internationalizations fields if needed. - You can(must) configure
seo_metafields generator, for example: keywords is:<postTitle>, key1, key2, <postTags>, ....
Examples of generated seo_url for some cases:
http://example.com/first-category/awesome-post- post1, cat1,seo_urlisawesome-posthttp://example.com/other-category/awesome-post- post2, cat2,seo_urlisawesome-postalso possiblehttp://example.com/first-category/awesome-post_- post3, cat1,seo_urlisawesome-post_(add underscore at end if name in post category already used)
Installation
Run
Configuration
Each view should have access to demi\seo\SeoViewBehavior methods.
So configure /frontend/config/main.php:
In model file add seo model behavior:
PHPdoc for model:
Change /frontend/views/layouts/main.php:
Usage
In "view.php" file for model:
or in controller:
Simple url rules example in '/frontend/config/main.php':
and change /frontend/controllers/PostController.php:
Get link to model view page. Based on behavior config values: viewRoute and additionalLinkParams
Render SEO:url and SEO:meta fields in the "/frontend/views/post/_form.php" file: