PHP code example of srg / laranx-seo

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

    

srg / laranx-seo example snippets

 php
$this->seo = new Seo;                    //this can be placed in constuctor
$this->seo->fill('about', 'Site Name');  //use page identifier and site name

//pass seo to view
 php
$product = Product::find($productId);

$seo = new Seo;                          //can be placed in constructor $this->seo                 
$seo->title($product->title);
$seo->description($product->description);
$seo->canonical('page-canonical');

$seo->opengraph('type', 'website');
$seo->opengraph('site_name', 'Site Name');
$seo->opengraph('title', $product->title);
$seo->opengraph('description', $product->description);
$seo->opengraph('url', 'page-canonical');
$seo->opengraphImage($product->imageUrl);

$seo->twitter('card', 'summary_large_image');
$seo->twitter('title', $product->title);
$seo->twitter('description', $product->description);
$seo->twitter('url', 'page-canonical');
$seo->twitter('image', $product->imageUrl);
            
//pass seo to view