PHP code example of contenir / contenir-resource

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

    

contenir / contenir-resource example snippets


use Contenir\Resource\Core\Metadata\MetaTagRenderer;
use Contenir\Resource\Core\Metadata\PageMetadataBuilder;
use Contenir\Resource\Core\ResourceManagerInterface;

$resources = $container->get(ResourceManagerInterface::class);
$page      = $resources->findActiveBySlug('about');

$metadata = $container->get(PageMetadataBuilder::class)->build($page, 'https://www.example.com/about');
echo $container->get(MetaTagRenderer::class)->render($metadata); // <title>, canonical link, meta tags

return [
    'contenir_resource' => [
        // Entity classes; each must extend the matching abstract entity.
        'resource_entity'            => Contenir\Resource\Core\Entity\ResourceEntity::class,
        'resource_collection_entity' => Contenir\Resource\Core\Entity\ResourceCollectionEntity::class,
        'resource_type_entity'       => Contenir\Resource\Core\Entity\ResourceTypeEntity::class,

        // The site's base URL for canonical URLs. Set it in production: without it the
        // request's own origin (from the client-controlled Host header) is used.
        'base_url'           => 'https://www.example.com',
        // Base URL for relative share-image paths; defaults to base_url, then the request origin.
        'image_base_url'     => 'https://cdn.example.com',
        'description_length' => 160,

        'summary_length'   => 249,
        // Service name of a SectionRendererInterface, used to summarise section content.
        'section_renderer' => null,
    ],
];