arrounded / metadata
The description of the module
Requires
- php: >=5.5.9
- illuminate/cache: ^5.1
- illuminate/contracts: ^5.1
- illuminate/support: ^5.1
- league/csv: ^7.1
Requires (Dev)
- fabpot/php-cs-fixer: 2.0.*@dev
- mockery/mockery: ^0.9.4
- phpspec/phpspec: ^2.2
- phpunit/phpunit: ^4.7
- symfony/var-dumper: ^2.7
This package is auto-updated.
Last update: 2019-11-15 14:46:51 UTC
README
Install
Via Composer
$ composer require arrounded/metadata
Usage
First add the module's service provider and facade to config/app.php
:
Arrounded\Metadata\ServiceProvider::class,
'Metadata' => Arrounded\Metadata\Facades\Metadata::class,
Then somewhere in your service provider, define your application's metadata. Either by passing it an array:
$this->app['arrounded.metadata']->setMetadata([ ['url' => 'foo.com', 'title' => Homepage', 'description' => 'foobar'], ]);
Or by indicating it the path to a CSV file:
metadata.csv
url,title,description
foo.com,Homepage,foobar
$this->app['arrounded.metadata']->setMetadataFromFile('metadata.csv');
Then in your views call the render
method on the facade. It'll look at the current URL and find the correct metadata for the page.
You can also pass it an array of additional metadata:
{{ Metadata.render() }} {{ Metadata.render({image: 'foo.com/logo.png'}) }}
By default all properties (except core ones such as title, description etc) are also wrapped in Twitter/Facebook graph metadata. You can disable this behavior by setting which properties should not be wrapped:
$this->app['arrounded.metadata']->setMetadataFromFile('metadata.csv'); $this->app['arrounded.metadata']->setUnwrapped(['property', 'other_property']);
Testing
$ composer test
License
The MIT License (MIT). Please see License File for more information.