trinityrank/laravel-schema-org-builder

Schema.org builder. Creating multiple nodes and makes relations between them.

v2.2.12 2022-09-07 13:11 UTC

This package is auto-updated.

Last update: 2024-05-07 16:48:08 UTC


README

Latest Version on Packagist Total Downloads

This package is used for building schema according to rules given on Schema.org in JSON-LD format. User can pass node properties for which schema should be created. Relation between nodes will also be created.

Installation

You can install the package via composer:

composer require trinityrank/laravel-schema-org-builder

Usage

Use Trinityrank\LaravelSchemaOrgBuilder\SchemaOrgBuilder. For ease of use, in each class you should initialize it inside __construct():

public function __construct()
{
    $this->schema_builder = new SchemaOrgBuilder();
}

To build the schema, you need to call getSchemaOrg(...) function which accepts next parameters:

 $entity - entity containing all the information, for which the schema is being built
 $node_properties - specific schema nodes for given entity, that should be created during this proces. At the end of this code block an example is given, containing nodes for some of the entities.
 $config - this parameter is optional. If available, here you should pass additional data in form of an array. At the moment available options are 'seo' and 'breadcrumbs'.

Example for '$node_properties':
[
    'home' => ['Organization', 'WebSite', 'WebPage'],
    'blog' => ['Organization', 'WebSite', 'WebPage', 'Article'],
    'news' => ['Organization', 'WebSite', 'WebPage', 'Article'],
    'money-page' => ['Organization', 'WebSite', 'WebPage', 'MoneyPage'],
    'review' => ['Organization', 'WebSite', 'WebPage', 'Review'],
    'blog-category' => ['Organization', 'WebSite', 'CollectionPage'],
    'blog-archive' => ['Organization', 'WebSite', 'CollectionPage'],
    'news-category' => ['Organization', 'WebSite', 'CollectionPage'],
    'news-archive' => ['Organization', 'WebSite', 'CollectionPage'],
    'reviews-category' => ['Organization', 'WebSite', 'CollectionPage'],
    'reviews-archive' => ['Organization', 'WebSite', 'CollectionPage'],
    'money-page-category' => ['Organization', 'WebSite', 'CollectionPage'],
]

Some of the data is being retrieved from config files.

From main.php:

- main.seo.home.meta_description
- main.mail_address

Add FOUNDING_DATE= (FOUNDING_DATE=2019-11-29) in .env. If not added default value is 01.01.2020

From package's config file schema-org-builder.php, that you should publish using php artisan vendor:publish --tag="schema-org-builder":

- schema-org-builder.general.logo
- schema-org-builder.general.name
- schema-org-builder.sameAs
- schema-org-builder.slogan
- schema-org-builder.general.inLanguage

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.