Download the PHP package cwsdigital/twill-metadata without Composer

On this page you can find all versions of the php package cwsdigital/twill-metadata. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package twill-metadata

Twill Metadata

Latest Version on Packagist Total Downloads

What it does

This package offers a simple way to add SEO metadata to your Twill models by providing a drop-in fieldset to add all the required fields into your model edit form. With sensible defaults, configurable fallbacks, and a global settings screen; this package should meet most of the needs for optimising meta tags within a site.

default and expanded views of twill metadata fieldset

Requirements

This package requires Laravel 8 or higher, PHP8 or higher, and Twill 3.0 or higher.

If you are looking for support for Twill 2 then make sure you use v1.3.0

Upgrade Notes

v1.0.0
This version introduces support for translated metadata. This means if you are upgrading from pre-v1.x version in an existing site with content you will need to migrate your content from the columns on the metadata table to the metadata_translations table.

v1.1.0
This version drops the translated columns from the metadata table.

WARNING! Do not upgrade to v1.1.x from a pre-1.0 installation on an existing site with content. YOU WILL LOSE DATA. If you wish to upgrade to this version, upgrade to v1.0.0 first, then perform any content migrations required. Only once you have moved all translatable data from the metadata table to the metadata_translations table should you upgrade to v1.1.x.

v1.4.0
This version drops support for Twill 2 as the package now uses the new Twill 3.x Settings rather than the legacy Twill 2.x

Note: When migrating from 1.3.0 to 1.4.0 any settings saved in the metadata-settings will need to be re-entered in the CMS in the new settings section.

Installation

First you want to install this dependency using composer, you can do this by running the following command:

Next we need to migrate the required database tables, you can do this by running the Laravel migration command:

Configuration

Adding metadata to a Module

If your module requires SEO Metadata (e.g. Pages) then you need to update the following files:

  1. ModuleModel
  2. ModuleController
  3. ModuleRepository

1 – Update the Module Model

Set your model to use the HasMetadata trait, and add the public property $metadataFallbacks.

Note: Your model also must include the HasMedias trait. This trait is used for generating for OpenGraph images.

2 – Update the Module Controller

In the Twill admin controller for the module you need to call the fieldset for the Metadata. We do this by making use of BladePartial.

3 – Update the Module Repository

Add use HandleMetadata onto your page repository.

Global Settings

Global settings for metadata allows you to set defaults for the following:

  1. Meta Title – this will be appended after the page meta title.
  2. Social Graph Image - this will render as the fallback sharing image
  3. Twitter (X) handle for the social card.

1 – Make sure the default social media image crop is in your twill.php config

2 – Create new settings file

3 – Add to Twill Settings Menu

How to use Metatags in your frontend code.

Firstly we need to set the Metadata.

Let's assume you have a module called Pages which has Metadata linked.

In your frontend routes you will have something like:

In the controller for your frontend application you can add the trait SetsMetadata and then use the setMetadata() function to set the metadata.

Under the hood this uses the artesaos/seotools package to set and display metadata. So you are free to not use the above helper, and manually set the meta tags as required. Or you can use the helper, and then use the methods provided by the package to amend the tags.

Outputting meta tags in your frontend

See the documentation for artesaos/seotools for more granular options, but the easiest way is shown below:

Customisation

You can publish the config for the package with the following command:

Within the config file is a fallbacks array, which can be customised according to your needs. This is a global config and will apply to all models that use the HasMetadata trait. i.e. in the config below if no description is entered in the metadata description field, the content field on the model will be used as the metadata description (all tags will be stripped).

To provide different fallback configurations to different models with the HasMetadata trait you can use the same array in the public $metadataFallBacks property on the model.

The two arrays are merged, so you only need to include the keys you wish to override from the global config.

If you wish to provide a default OpenGraph Type and Twitter Card Type then you can add the following two public properties to your model:

You can publish the views for the package with the following command:

You can publish the language files for the package with the following command:


All versions of twill-metadata with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
area17/twill Version ^3.0
artesaos/seotools Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cwsdigital/twill-metadata contains the following files

Loading the files please wait ....