Download the PHP package coreplex/meta without Composer

On this page you can find all versions of the php package coreplex/meta. 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 meta

Meta

A PHP 5.4 Page-Meta Container that is easily extensible

Installation & Requirements

This package requires PHP 5.4 or above. To install, simply add this line to your composer.json file under the require key

Laravel Integration

To use this package with Laravel, just take the following steps after installation:

Add the service provider to the providers array in your config/app.php file

You then need to publish the required assets using the command line. Run this command to provision this action

You will then want to migrate the database tables which will act as a store for any meta items

Once you've done this, you can go ahead and start using the package, and populating the database with some example meta information.

To start, let's add in a default meta group to see it in action. Run this piece of code to create a default piece of meta:

This will insert the default meta record into the database, which will be used on every single page, with any addition records merged on top (unless it is overwritten, which is easy to do!). You don't have to do this, but it is a nice way to add a default set of meta data.

To render the meta data in your view, all you have to do is echo out the meta container that is bound to the app, and it will be turned into clean html.

Using default configuration, this would output:

Don't forget, if you are using laravel blade, you must use the non-escaping blade echo tags ({!! !!}) or the meta will not be output correctly.

If you want to completely overwrite the meta, retrieve the meta container from your application and use the set() method to override it. You can pass in an instance of a Coreplex\Meta\Contracts\Group (The Coreplex\Meta\Eloquent\Meta model implements this), or just a string identifier which will be used to find it from the store.

Will then output this to the page when the meta is echoed out:

If you only wish to merge but not overwrite the default styles, instead use the add() method on the container.

Which will then output a merged variant of the two meta groups we inserted

You can merge as many meta groups together, keeping in mind that the group which was last merged will overwrite any meta items that precede it which it also has

Configurating Meta Templates

The meta library knows how to render out each type of meta element differently. It does this through the config file.

In your config folder, you will find meta.php and drivers.php. Inside meta.php, you will see something similar to this:

This array defines how every element is display on the page. Here are each of the configuration keys you can use on each element:

If there is no template for the key specified in the meta_items table, it will use the meta.default value as the template, which by default renders a <meta name="{key}" content="{data}"> element, unless you choose to change this behaviour.

More data in a single meta item

If a meta is empty (has no closing tag), and the string in the "data" column of the meta_items record is JSON encoded, it will loop around each key and put it in as an attribute:

Would yield this when rendered

You can just pass a standard string to the data column if you don't want multiple attributes.

Using the HasMetaData Trait

We've created a handy trait when you can place on your models to immediately allow it to have meta. This is done behind the scenes using a polymorphic relationship. To get this to work, simply add this to the first line of your model class:

This will add two methods to your model; hasMeta and getMeta. Using these methods you can check if the model has meta data and then retrieve it. You can also access the meta by using the meta relationship, you can use this to create and update your meta data.

When you retrieve meta it will return a Coreplex\Meta\Eloquent\Meta instance which has all the items bound to it, as we have seen in the above examples. This can then be set by doing something along the lines of this in our controllers:

This works extremely well if you want to bind meta data to any database table in your system. Groups of page-meta can be bound to all sorts of things, from a pages table record in the database to a products table record.

You could quite easily write a fallback for any items which don't have a meta item by doing something like this in your controller

Using the MetaVariant Trait

We've also added the ability to have meta variants, this is useful if you have multiple countries, websites, etc. and you need to have different meta per variant.

To get started you need to implement the Variant interface, and then if you are using a model use the MetaVariant trait.

Then you can provide the meta variant when setting or adding the meta, and it will load the meta data for the variant.

If you are using a key rather than a model to set your meta, you can pass the variant as the second parameter.

Non-Laravel Usage

A non-laravel usage guide isn't currently available. If you are however integrating with Laravel 5, follow the above steps


All versions of meta with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
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 coreplex/meta contains the following files

Loading the files please wait ....