PHP code example of code4mk / lara-head
1. Go to this page and download the library: Download code4mk/lara-head library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
code4mk / lara-head example snippets
use Khead;
class Test
{
public function home()
{
Khead::setMeta('viewport',[
"name" => "viewport",
"content"=>"width=device-width, initial-scale=1"
]);
}
}
{{ Khead::getMeta('viewport') }}
// <meta name="bladeport" content="width=device-width, initial-scale=1">
Khead::setLink('author',[
"rel"=>"author",
"href"=>"humans.txt"
]);
// blade
{{ Khead::getLink('author') }}
// <link rel="author" href="humans.txt">
Khead::setScript('one',[
"src"=>"test.js",
]);
// blade
{{ Khead::getScript('one') }}
// <script src="test.js"></script>
Khead::setTitle('this is a title');
// blade
{{ Khead::getTitle() }}
Khead::setOg([
"app_id" => [
"property"=>"fb:app_id",
"content"=>"123456789"
],
"url" => [
"property"=>"og:url",
"content"=>"https://example.com/page.html"
],
"type" => [
"property"=>"og:type", "content"=>"website"
],
"title" => [
"property"=>"og:title",
"content"=>"Content Title"
],
"image" => [
"property"=>"og:image",
"content"=>"https://example.com/image.jpg"
],
"description" => [
"property"=>"og:description",
"content"=>"Description Here"
],
"site_name" => [
"property"=>"og:site_name",
"content"=>"Site Name"
],
"locale" => [
"property"=>"og:locale",
"content"=>"en_US"
],
"author" => [
"property"=>"article:author",
"content"=>"@code4mk"
]
]);
// blade
{{ Khead::getOg() }}
Khead::setTwitCards([
"card" => [
"name" => "twitter:card",
"content"=>"summary"
],
"site" => [
"name"=>"twitter:site",
"content"=>"@code4mk"
],
"creator" => [
"name"=>"twitter:creator",
"content"=>"@code4mk"
],
"url" => [
"name"=>"twitter:url",
"content"=>"https://code4mk.org"
],
"title" => [
"name"=>"twitter:title",
"content"=>"Content Title"
],
"description" => [
"name"=>"twitter:description",
"content"=>"Content description less than 200 characters"
],
"image" => [
"name"=>"twitter:image",
"content"=>"https://code4mk.org/image.jpg"
],
"dnt" => [
"name"=>"twitter:dnt",
"content"=>"on"
]
]);
// blade
{{ Khead::getTwitCards() }}