PHP code example of maximaster / meta-bind

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

    

maximaster / meta-bind example snippets



$csv = new SplFileObject(__DIR__ . '/seo.csv');
$storage = MetaStorage::fromCsv($csv, separator: ';');
$meta = $storage->firstFit([
    'url' => $_SERVER['REQUEST_URI'],
    'url.path' => parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),
]);
if ($meta === null) {
    return;
}

$supportedMetas = [
    'h1',
    'title',
    'robots',
    'keywords',
    'description',
    'canonical',
];

global $APPLICATION;
foreach ($supportedMetas as $supportedMeta) {
    if (array_key_exists($supportedMeta, $meta) === false) {
        continue;
    }

    // Optionally, if your meta data has templates, process
    // {$meta[$supportedMeta]} here to replace supported placeholders.

    $APPLICATION->SetPageProperty($supportedMeta, $meta[$supportedMeta]);
}