Small package to generate meta tags easily in your Laravel app
First, pull in the package through Composer.
"require": {
"foxted/meta": "1.1.*"
}
Then include the service provider within app/config/app.php
.
'providers' => [
'Foxted\Meta\MetaServiceProvider'
];
Add a facade alias to this same file at the bottom:
'aliases' => [
'Meta' => 'Foxted\Meta\Facades\Meta'
];
And finally publish the view & config files:
php artisan view:publish foxted/meta
php artisan config:publish foxted/meta
Defaults values are set in the config file, to override them, after you ran the php artisan config:publish foxted/meta
command, navigate to app/config/packages/foxted/config.php
and change the values as you want.
You can also delete them entirely if you do not want any defaults values, just be sure to keep the app/config/packages/foxted/config.php
file and return an empty array, like so:
<?php
return [];
Within your controllers, before rendering your view, generate your tags:
public function index()
{
Meta::title("My amazing website"); // <title>My amazing website</title>
Meta::name("keywords", "awesome, keywords"); // <meta name="keywords" content="awesome, keywords">
Meta::name("description", "The best website you've ever seen"); // <meta name="description" content="The best website you've ever seen">
Meta::equiv("content-type", "text/html; charset=UTF-8"); // <meta http-equiv="content-type" content="text/html; charset=UTF-8">
return View::make("index");
}
To show your meta block in your view, just use the following Blade directive:
@meta
Any ideas are welcome. Feel free the submit any issues or pull requests.
Enjoy ;)