PHP code example of hazaveh / php-link-preview

1. Go to this page and download the library: Download hazaveh/php-link-preview 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/ */

    

hazaveh / php-link-preview example snippets


use Hazaveh\LinkPreview\Client;  
  
Returns an instance of Hazaveh\LinkPreview\Model\Link
* {title, description, image, icon, locale}
*/

$preview = $client->parse("https://hazaveh.net/2023/07/re-inventing-bookmarks-for-teams/");

class CustomParser implements ParserInterface  
{  
    public function parse(string $url): Link  
    {  
        return new Link(url: $url);  
    }  
}  
  
$client = new Client(new CustomParser());