PHP code example of nepada / meta-control

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

    

nepada / meta-control example snippets


protected function createComponentMeta(): Nepada\MetaControl\MetaControl
{
    $control = $this->metaControlFactory->create();
    $control->setDescription('Lorem ipsum');
    return $control;
}

// <meta charset="utf-8">
$control->setCharset('utf-8');
$control->getCharset(); // 'utf-8'

// <meta name="author" content="John Doe">
$control->setMetadata('author', 'Jon Doe');
$control->getMetadata('author'); // 'Jon Doe'

// <meta property="og:title" content="Foo title">
$control->setProperty('og:title', 'Foo title');
$control->getProperty('og:title'); // 'Foo title'

// <meta http-equiv="content-type" content="text/html; charset=UTF-8">
$control->setPragma('content-type', 'text/html; charset=UTF-8');
$control->getPragma('content-type'); // 'text/html; charset=UTF-8'

// <meta name="author" content="John Doe">
$control->setAuthor('Jon Doe');
$control->getAuthor(); // 'Jon Doe'

// <meta name="description" content="Lorem ipsum">
$control->setDescription('Lorem ipsum');
$control->getDescription(); // 'Lorem ipsum'

// <meta name="keywords" content="foo, bar, baz">
$control->setKeywords('foo', 'bar');
$control->addKeyword('baz');
$control->getKeywords(); // ['foo', 'bar', 'baz']

// <meta name="robots" content="noindex, nofollow">
$control->setRobots('noindex, nofollow');
$control->getRobots(); // 'noindex, nofollow'