PHPackages                             fsmdev/laravel-page-attributes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fsmdev/laravel-page-attributes

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fsmdev/laravel-page-attributes
==============================

Tool for manage meta and other page attributes for seo

1.0.4(6y ago)076MITPHPPHP &gt;=7.1.0

Since Feb 14Pushed 6y agoCompare

[ Source](https://github.com/fsmdev/laravel-page-attributes)[ Packagist](https://packagist.org/packages/fsmdev/laravel-page-attributes)[ RSS](/packages/fsmdev-laravel-page-attributes/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (6)Used By (0)

Laravel 5 Page Attributes: meta and other SEO-important attributes
==================================================================

[](#laravel-5-page-attributes-meta-and-other-seo-important-attributes)

[English](https://github.com/fsmdev/laravel-page-attributes/blob/master/README.md) | [Русский](https://github.com/fsmdev/laravel-page-attributes/blob/master/README.RU.md)

Package for **Laravel 5**, that helps manage metadata and other page attributes, generate html tags, get page attributes from data base and make own page attributes and html templates for they.

### Installation

[](#installation)

```
composer require fsmdev/laravel-page-attributes

```

##### For Laravel 5.4 and earlier versions

[](#for-laravel-54-and-earlier-versions)

If you use Laravel 5.5 or higher package discover automatically. For earlier versions add provider and alias in config/app.php file.

```
# config/app.php

'providers' => [
  ...
  Fsmdev\LaravelPageAttributes\PageAttributesServiceProvider::class,
  ...
];

'aliases' => [
  ...
  'PageAttributes' => Fsmdev\LaravelPageAttributes\Facades\PageAttributes::class,
  ...
];
```

### Configuration

[](#configuration)

If you want to change multilanguage mode this can be done by setting the value of the `FSMDEV_MULTI_LANGUAGE` property in the .env file. By default multi language mode is disabled (false).

For changin

To change other settings, use the file config/page\_attributes.php. The file can be created manually or using the command:

```
php artisan vendor:publish --provider="Fsmdev\LaravelPageAttributes\PageAttributesServiceProvider" --tag=config

```

### Basic usage

[](#basic-usage)

Most of the operations described below are performed using the facade PageAttributes.

```
use Fsmdev\LaravelPageAttributes\Facades\PageAttributes;
```

#### Setting page attributes

[](#setting-page-attributes)

To set the attributes of the page (for example, metadata), the **set** method of the PageAttributes facade is used.

```
set ( string|array $name, string $value ) : void

```

```
PageAttributes::set('title', 'Awesome Page');

PageAttributes::set('h1', $post->name);

# Own attribute
PageAttributes::set('my_attribute', 'My Value');
```

#### Default values

[](#default-values)

You can set default values for page attributes. Initially, `charset` and` viewport` attributes have default values.

```
# config/page_attributes.php

'default' => [

  # Default value for title
  'title' => 'Awesome Page',

  # Override charset
  'charset' => 'windows-1251',
],
```

#### Getting page attributes

[](#getting-page-attributes)

To get the page attribute values, use the **get** method of the PageAttributes facade.

```
get ( string $name) : string

```

#### Getting html

[](#getting-html)

To get html attributes of the page, the method **html** of the PageAttributes facade is used.

```
html ( string $name) : string

```

You can also use Blade directives: `@charset`, `@viewport`, `@title`, `@description`, `@keywords`, `@canonical`.

```
{{ PageAttributes::html('title') }}
```

or

```
@title
```

#### Creating your own templates

[](#creating-your-own-templates)

The **html** method uses the predefined html code templates to generate the result. These templates can override or add new templates for your own attributes.

```
# config/page_attributes.php

'html_templates' => [

    # Overriding template for h1
    'h1' => '',

    # Creating template for own attribute
    'my_attribute' => '{value}',
],
```

The configuration specified above can be used as follows.

Controller:

```
PageAttributes::set('my_attribute', 'My Value');
```

View:

```
{{ PageAttributes::html('my_attribute') }}
```

Page output:

```
My Value
```

#### Default view usage

[](#default-view-usage)

The package includes a view that displays the following tags: charset, viewport, title, description, keywords, canonical. To use it, add it to the `` block of the page.

```
@include('page_attributes::meta')
```

To change the view you need to create a file `resouces/views/vendor/page_attributes/meta.blade.php`. You can do this automatically with the command:

```
php artisan vendor:publish --provider="Fsmdev\LaravelPageAttributes\PageAttributesServiceProvider" --tag=view

```

#### Overriding the model used in the facade

[](#overriding-the-model-used-in-the-facade)

Change configuration parameter `class` for change model that uses in PageAttributes facade.

### Page Context usage

[](#page-context-usage)

For separation data and view, it is better to store metadata in a database. When a page is associated with an object of some kind of model, it is easily solved by adding metadata fields to the model. But what to do for pages like main or categories? The page context mechanism offers a solution.

#### Installation

[](#installation-1)

```
php artisan vendor:publish --provider="Fsmdev\LaravelPageAttributes\PageAttributesServiceProvider" --tag=context

php artisan migrate

```

After installation, a file will appear in the app/ConstantsCollections folder with the `PageAttributesContext` class inherited from [ConstantCollection](https://github.com/fsmdev/constants-collection), the table\_attributes table will also appear in the database.

#### Conllection: PageAttributesContext

[](#conllection-pageattributescontext)

In this class, you must specify a set of constants corresponding to the pages for which the mechanism for obtaining attributes by context will be used. Constant values must be of type `TYNIINT UNSIGNED`. It is also recommended to set the names of the constants in the **propertiesName** method. These names can be further used to create a CRUD of the PageAttribute class.

You can read more about working with the ConstantsCollection class [here](https://github.com/fsmdev/constants-collection).

```
# app/ConstantsCollections/PageAttributesContext.php

const INDEX = 5;
const CONTACTS = 10;
const BLOG = 15;

protected static function propertiesName()
{
    return [
        self::INDEX => 'Home Page',
        self::CONTACTS => 'Contacts Page',
        self::BLOG => 'Blog',
    ];
}
```

#### Model: PageAttribute

[](#model-pageattribute)

The package includes a model `Fsmdev\LaravelPageAttributes\Models\PageAttribute` with table `page_attributes`. The table (model) contains the following fields:

**context** (UNSIGNED TINYINT) - contains the value of the constant corresponding to the context for which the attribute is being set.

**language** (CHAR(2) NULLABLE) - language / locale for which the attribute value is specified. If the use of `multi_language` is set to false, this attribute is not taken into account when retrieving data.

**name** (char(30)) - attribute name.

**value** (text) - attribute value.

Fields **context**, **language** and **name** form a unique index and are key to defining an attribute value.

An example of filling data:

contextlanguagenamevalue5NULLh1Awesome Site5NULLtitleWelcome to Awesome Site5NULLmy\_attributeMy Value15NULLh1My Blog##### Context usage

[](#context-usage)

To set the page attribute context, use the **context** method of the PageAttributes facade.

```
context ( integer $context) : void

```

```
PageAttributes::context(PageAttributesContext::INDEX);
```

When the context is set, the **get**, **html** methods and blade directives will use the PageAttribute model to find the values of the required attribute:

```
{{ PageAttributes::html('title'); }}
```

Returns (for the case when the data is filled as in the table above):

```
Welcome to Awesome Site
```

### Variables

[](#variables)

In page attributes you can use variables. Default syntax:

```
{--variable_name--}

```

Opening and closing symbols of variable you can change in configuration parameters `variable_open` and `variable_close`.

#### Variable value set

[](#variable-value-set)

For variable value set this methods of PageAttributes facade is used:

```
context ( integer $context, array|null $variables = []) : void

variables ( array $variables) : void

variable ( string $name, string $value) : void

```

First 2 can get array as parameter. Keys of array are variables names.

#### Default values

[](#default-values-1)

Default values of variables can be set in configuration parameter `default_variables`.

#### Example

[](#example)

For page context POST\_SHOW set title attribute:

```
{--post_name--} | Blog | {--site_name--}

```

Code:

```
# config/page_attributes.php

'default_variables' => [
    'site_name' => 'Awesome Site',
],

# Controller

PageAttributes::context(PageAttributesContext::POST_SHOW, [
    'post_name' => $post->name, // F.e. Post Name is 'About Me'
]);
```

Result in title:

```
About Me | Blog | Awesome Site

```

### The priority of attribute value selection

[](#the-priority-of-attribute-value-selection)

When determining the attribute value, the source priority is as follows:

1. Attributes set directly by the method **set**;
2. Attributes received by context (if set);
3. Attribute default values.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~87 days

Total

5

Last Release

2294d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b3f0b661b62e3ca4f33d78685ad68d7fca9b93061653df5be63cb06d62ed7bf?d=identicon)[fsmdev](/maintainers/fsmdev)

---

Top Contributors

[![fsmdev](https://avatars.githubusercontent.com/u/34908771?v=4)](https://github.com/fsmdev "fsmdev (29 commits)")

---

Tags

laravelseometalaravel-seolaravel meta

### Embed Badge

![Health badge](/badges/fsmdev-laravel-page-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/fsmdev-laravel-page-attributes/health.svg)](https://phpackages.com/packages/fsmdev-laravel-page-attributes)
```

###  Alternatives

[lionix/seo-manager

SEO Manager for Laravel Framework

2165.4k](/packages/lionix-seo-manager)[fomvasss/laravel-meta-tags

A package to manage SEO (meta-tags, xml-fields, etc.)

3028.9k](/packages/fomvasss-laravel-meta-tags)[torann/laravel-meta-tags

A package to manage Header Meta Tags

65273.3k4](/packages/torann-laravel-meta-tags)[calotype/seo

A package containing SEO helpers.

722.6k](/packages/calotype-seo)[f9webltd/laravel-meta

Render meta tags in your Laravel application

4049.5k](/packages/f9webltd-laravel-meta)[larament/seokit

A complete SEO package for Laravel, covering everything from meta tags to social sharing and structured data.

411.9k](/packages/larament-seokit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
