PHP code example of crumby / meta-resolver

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

    

crumby / meta-resolver example snippets


'providers' => [
    ......................
    'Crumby\MetaResolver\MetaResolverServiceProvider',
    ........................
 ];
 
 'aliases' => [ 
    ......................
    'MetaResolver' => 'Crumby\MetaResolver\Facades\MetaResolver',
    ......................
 ];


namespace App\Resolvers;
use Crumby\MetaResolver\Contracts\MetaResolver as MetaResolver;

class CreativeWorkResolver implements MetaResolver {
    const IRI_FRAGMENT = '#creative';
    protected $service;
    public function __construct($service) {
        $this->service = $service;
    }
    
    public function type() {
        return 'CreativeWork';
    }
    
    public function hasPart() {
        return [
            "mainEntity" => [
                "author" => "Person" , 
                "publisher" => "Organization"
                ], 
            "breadcrumb" => "BreadcrumbList"
            ];
    }
    
    public function title() {
        return $this->service->title();
    }

    public function description() {
        return $this->service->description();
    }
    
    public function publishedAt() {
        return $this->service->content()->created_at->format('Y-m-d');
    }
    
    public function modifiedAt() {
        return $this->service->content()->updated_at->format('Y-m-d');
    }
    
    public function image() {
        return false;
    }
    
    public function url() {
        return $this->service->url();
    }
    
    public function iri() {
        return $this->url() . '/' . self::IRI_FRAGMENT;
    }
    
    public function schema($

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function article(ContentPackage $package, ContentItem $article) {
        \MetaResolver::addMeta(new CreativeWorkResolver($article), $article);
        $collection = new FrontPackages();
        return view('pages.package', ['collection' => $collection]);
    }