PHP code example of torann / meta-tags

1. Go to this page and download the library: Download torann/meta-tags 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/ */

    

torann / meta-tags example snippets


$og = new \MetaTags\Manager();

$og->type('article')
    ->title('All Trains Run on Time')
    ->description('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.')
    ->url()
    ->profile([
        'username' => 'Torann'
    ])
    ->image('https://upload.wikimedia.org/wikipedia/commons/9/95/Train_Station_Panorama.jpg')
    ->twitterImageAlt('Train Station in Upstate New York')
    ->twitterSite('@lyften', [
        'id' => '4Df665K',
    ])
    ->siteName('My Train Website')
    ->video('http://examples.opengraphprotocol.us/media/video/train.mp4', [
        'secure_url' => 'https://examples.opengraphprotocol.us/media/video/train.mp4'
    ]);

echo $og; // Will output all meta tags

[
    'validate' => false,
    'twitter' => true,
    'truncate' => [
        'description' => 160,
        'twitter:title' => 70,
        'og:description' => 200,
        'twitter:description' => 200,
    ],
]

$og = new \MetaTags\Manager([
    'validate' => true,
    'twitter' => false,
    'truncate' => [
        'description' => 200,
    ],
]);