monomelodies / metaculous
Metadata helpers
Installs: 200
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/monomelodies/metaculous
Requires
- twig/twig: ^2|^3
Requires (Dev)
- toast/unit: ^2
README
Metadata helpers
A few simple helpers to generically add metadata tag (description, keywords) to your HTML pages, based on page content.
Installation
Composer (recommended)
$ composer install --save monomelodies/metaculous
Manual
Download or clone the files, and add /path/to/metaculous/src
to your
autoloader for classes in the Metaculous
namespace.
Usage
Instantiate the Parser:
<?php use Metaculous\Parser; $parser = new Parser;
Generate a short description based on random text (e.g. page content from a database):
<?php echo '<meta name="description" content="'.$parser->description($bodyText).'">';
Generate top 10 keywords based on the same text:
<?php echo '<meta name="keywords" content="'.implode(', ', $parser->keywords($bodyText)).'">';
Of course, you could also use the keywords to e.g. display a tag cloud.