PHP code example of mh / collection

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

    

mh / collection example snippets




eoIp2\Database\Reader;

$reader = new Reader(__DIR__.'/GeoLite2-City/GeoLite2-City.mmdb');
$record = $reader->city('84.227.20.193');

var_dump($record->country->isoCode);



$title = 'This is my awesome blog';
$description = 'This post is about loan and good stuff';
$url = 'http://this.blog/1';
$author = 'this.blog';
$publisher = $author;
$datePublished = '2019-01-01';
$image = 'http://this.image.url';

$json = \JsonLd\Context::create('article', [
    'headline' => $title,
    'description' => $description,
    'mainEntityOfPage' => $url,
    'author' => $author,
    'publisher' => [
        'name' => $publisher,
    ],
    'datePublished' => $datePublished,
    'image' => $image,
]);

echo $json;



hrisKonnertz\OpenGraph\OpenGraph;

$title = 'This is my blog';
$image = 'http://www.image.url';
$description = 'This is going to happen in 2019';
$url = 'http://this.blog.url';

$og = new OpenGraph();
$og->type('article')
    ->title($title)
    ->image($image)
    ->description($description)
    ->url($url)
    ;

var_dump($og->renderTags());



drmonkeyninja\SocialShareUrl\SocialShareUrl;

$SocialShareUrl = new SocialShareUrl();
$url = $SocialShareUrl->getUrl('facebook', 'http://example.com');

var_dump($url);