PHP code example of anthonypauwels / metadata

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

    

anthonypauwels / metadata example snippets


Anthonypauwels\Metadata\Laravel\ServiceProvider::class,

'Metadata' => Anthonypauwels\Metadata\Laravel\Metadata::class,

$metadata = metadata();

metadata()->title( 'Website title' );
metadata()->description( 'Website description' );
metadata()->url( url()->full() );
metadata()->author( 'Anthony Pauwels' );
metadata()->opengraphImage( asset('/img/facebook_meta.jpg'), ['width' => 1200, 'height' => 600, 'type' => 'JPEG'] );
metadata()->twitterImage( asset('/img/twitter_meta.jpg'), ['width' => 600, 'height' => 400, 'type' => 'JPEG'] );
metadata()->twitterCard( 'app' );
metadata()->type( 'website' );

use Anthonypauwels\Metadata\Laravel\Metadata;

Metadata::title( 'Website title' );

/**
 * Return the Metadata instance
 */
function getInstance():Metadata; 

/**
 * Set an array of tags
 */
function setTags(array $tags): Metadata;

/**
 * Set the page title in meta tags
 */
function title(string $title, int $flags = Metadata::ALL): Metadata;

/**
 * Set the page description in meta tags
 */
function description(string $description, int $flags = Metadata::ALL): Metadata;

/**
 * Set the image for the page used for cards inside app; Can be used to set image options like size or mimetype
 */
function image(string $url, array $options = [], int $flags = Metadata::TWITTER | Metadata::OPENGRAPH): Metadata;

/**
* Shortcut to image() method for Twitter Card
 */
function twitterImage(string $url, array $options = []): Metadata

/**
* Shortcut to image() method for Opengraph
 */
function opengraphImage(string $url, array $options = []): Metadata

/**
 * Set the page URL
 */
function url(string $url, int $flags = Metadata::TWITTER | Metadata::OPENGRAPH): Metadata;

/**
 * Set the content og type
 */
function type(string $type = 'website', array $options = []): Metadata;

/**
 * Set the author's name
 */
function author(string $author): Metadata;

/**
 * Set the Twitter card format
 */
function twitterCard(string $card_type = 'summary'): Metadata;

/**
 * Set the Twitter website profile
 */
function twitterSite(string $twitter_site): Metadata;

/**
 * Set the twitter author profile
 */
function twitterCreator(string $twitter_creator): Metadata;

/**
 * Set the facebook app_id
 */
function fbAppId(string $app_id): Metadata;

/**
 * Set the facebook admins tag
 */
function fbAdmins(string $admins): Metadata;

/**
 * Set the og:site_name tag
 */
function siteName(string $site_name): Metadata;

/**
 * Disable (or enable if $value is true) the pinterest-rich-pin
 */
function disablePinterestRichPin(bool $value = true): Metadata;

/**
 * Set the robot meta tag
 */
function robots(...$values): Metadata;

/**
 * Set a meta tag with given key and given value
 */
function meta(string $name, string $value): Metadata;

/**
 * Set a meta tag for Twitter
 */
function twitter(string $name, string $value, string $prefix = Metadata::TWITTER_PREFIX): Metadata;

/**
 * Set a meta tag for Opengraph
 */
function opengraph(string $name, string $value, string $prefix = Metadata::OPENGRAPH_PREFIX): Metadata;

/**
 * Generate the HTML code of meta tags
 */
function toHtml(int $flags = Metadata::ALL):string;

/**
 * Print the generated HTML code
 */
function print(int $flags = Metadata::ALL):void;

/**
 * Return the HTML code of meta tags with default parameter
 */
function __toString():string;