PHPackages                             qmagix/laravel-tagging - 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. [Database &amp; ORM](/categories/database)
4. /
5. qmagix/laravel-tagging

ActiveLibrary[Database &amp; ORM](/categories/database)

qmagix/laravel-tagging
======================

Use PHP traits to extend Laravel Eloquent Models to allow Tags. Models can be marked as Taggable. Derived from rtconner's work for compatibility with MySql 5.6

2.2.1(9y ago)021MITPHPPHP &gt;=5.5.0

Since Mar 7Pushed 9y ago1 watchersCompare

[ Source](https://github.com/qmagix/laravel-tagging)[ Packagist](https://packagist.org/packages/qmagix/laravel-tagging)[ Docs](https://smartersoftware.net/packages/laravel-tagging-taggable)[ RSS](/packages/qmagix-laravel-tagging/feed)WikiDiscussions laravel-5 Synced 2w ago

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

Laravel Taggable Trait
======================

[](#laravel-taggable-trait)

This package is a fork from rtconner's same name package to support db string length issue that is not compatible with MySQL 5.6.

This package is not meant to handle javascript or html in any way. This package handles database storage and read/writes only.

There are no real limits on what characters can be used in a tag. It uses a slug transform to determine if two tags are identical ("sugar-free" and "Sugar Free" would be treated as the same tag). Tag display names are run through Str::title()

[Laravel/Lumen 5 Documentation](https://github.com/qmagix/laravel-tagging/tree/laravel-5)
[Laravel 4 Documentation](https://github.com/qmagix/laravel-tagging/tree/laravel-4)

#### Composer Install (for Laravel 5.3/Lumen 5)

[](#composer-install-for-laravel-53lumen-5)

```
composer require qmagix/laravel-tagging
```

#### Install and then Run the migrations

[](#install-and-then-run-the-migrations)

The service provider does not load on every page load, so it should not slow down your app.

```
'providers' => array(
	\Qmagix\Tagging\Providers\TaggingServiceProvider::class,
);
```

```
php artisan vendor:publish --provider="Qmagix\Tagging\Providers\TaggingServiceProvider"
php artisan migrate
```

###### Lumen 5 Installation

[](#lumen-5-installation)

Lumen does not have a vendor:publish command, so you will need to create or copy the provided migrations and config file into their respective directory.

In app\\bootstrap\\app.php

```
// Add this line in your config section
$app->configure('tagging');
// Add this line in your service provider section
$app->register(Qmagix\Tagging\Providers\LumenTaggingServiceProvider::class);
```

After these two steps are done, you can edit config/tagging.php with your prefered settings.

#### Setup your models

[](#setup-your-models)

```
class Article extends \Illuminate\Database\Eloquent\Model {
	use \Qmagix\Tagging\Taggable;
}
```

#### Quick Sample Usage

[](#quick-sample-usage)

```
$article = Article::with('tagged')->first(); // eager load

foreach($article->tags as $tag) {
	echo $tag->name . ' with url slug of ' . $tag->slug;
}

$article->tag('Gardening'); // attach the tag

$article->untag('Cooking'); // remove Cooking tag
$article->untag(); // remove all tags

$article->retag(array('Fruit', 'Fish')); // delete current tags and save new tags

$article->tagNames(); // get array of related tag names

Article::withAnyTag(['Gardening','Cooking'])->get(); // fetch articles with any tag listed

Article::withAllTags(['Gardening', 'Cooking'])->get(); // only fetch articles with all the tags

Qmagix\Tagging\Model\Tag::where('count', '>', 2)->get(); // return all tags used more than twice

Article::existingTags(); // return collection of all existing tags on any articles
```

[More examples in the documentation](docs/usage-examples.md)

### Tag Groups

[](#tag-groups)

You can create groups with the following artisan command

```
php artisan tagging:create-group MyTagGroup
```

Set the tag group for a tag

```
$tag->setGroup('MyTagGroup');
```

To get all the tags in a certain group

```
Tag::inGroup('MyTagGroup')->get()
```

Check if a tag is in a group

```
$tag->isInGroup('MyTagGroup');
```

### Configure

[](#configure)

[See config/tagging.php](config/tagging.php) for configuration options.

### Further Documentation

[](#further-documentation)

[See the docs/ folder](docs) for more documentation.

#### Upgrading Laravel 4 to 5

[](#upgrading-laravel-4-to-5)

This library stores full model class names into the database. When you upgrade laravel and you add namespaces to your models, you will need to update the records stored in the database. Alternatively you can override Model::$morphClass on your model class to match the string stored in the database.

#### Credits

[](#credits)

- Robert Conner -

#### Further Reading

[](#further-reading)

- [Laravel News article on tagging with this library](https://laravel-news.com/2015/10/how-to-add-tagging-to-your-laravel-app/)
- [3rd Party Posting on installation with Twitter Bootstrap 2.3](http://blog.stickyrice.net/archives/2015/laravel-tagging-bootstrap-tags-input-rtconner)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 82.3% 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 ~38 days

Recently: every ~54 days

Total

25

Last Release

3578d ago

Major Versions

0.5.2 → 1.0.72015-05-29

1.1.3 → 2.0.02015-09-06

0.5.4 → 2.0.82016-02-07

PHP version history (5 changes)0.1.0PHP &gt;=5.4.0

0.2.2PHP &gt;=5.3.0

0.5.1PHP ~5.3

2.0.0PHP &gt;=5.5.0

0.5.4PHP ~5.3|~7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7896945?v=4)[qmagix](/maintainers/qmagix)[@qmagix](https://github.com/qmagix)

---

Top Contributors

[![rtconner](https://avatars.githubusercontent.com/u/334533?v=4)](https://github.com/rtconner "rtconner (200 commits)")[![oschettler](https://avatars.githubusercontent.com/u/124634?v=4)](https://github.com/oschettler "oschettler (6 commits)")[![jakejohns](https://avatars.githubusercontent.com/u/174708?v=4)](https://github.com/jakejohns "jakejohns (5 commits)")[![epic-kaso](https://avatars.githubusercontent.com/u/5386122?v=4)](https://github.com/epic-kaso "epic-kaso (3 commits)")[![qhuang08](https://avatars.githubusercontent.com/u/10619110?v=4)](https://github.com/qhuang08 "qhuang08 (3 commits)")[![jbardnz](https://avatars.githubusercontent.com/u/1628446?v=4)](https://github.com/jbardnz "jbardnz (3 commits)")[![vkbansal](https://avatars.githubusercontent.com/u/5930351?v=4)](https://github.com/vkbansal "vkbansal (2 commits)")[![computeus](https://avatars.githubusercontent.com/u/388505?v=4)](https://github.com/computeus "computeus (2 commits)")[![marcusmoore](https://avatars.githubusercontent.com/u/1141514?v=4)](https://github.com/marcusmoore "marcusmoore (2 commits)")[![Uibar](https://avatars.githubusercontent.com/u/120263812?v=4)](https://github.com/Uibar "Uibar (2 commits)")[![davericher](https://avatars.githubusercontent.com/u/6945951?v=4)](https://github.com/davericher "davericher (1 commits)")[![james2doyle](https://avatars.githubusercontent.com/u/1425304?v=4)](https://github.com/james2doyle "james2doyle (1 commits)")[![darkliquid](https://avatars.githubusercontent.com/u/31256?v=4)](https://github.com/darkliquid "darkliquid (1 commits)")[![kirananils](https://avatars.githubusercontent.com/u/2004110?v=4)](https://github.com/kirananils "kirananils (1 commits)")[![KousukeKun](https://avatars.githubusercontent.com/u/4623283?v=4)](https://github.com/KousukeKun "KousukeKun (1 commits)")[![vinicius73](https://avatars.githubusercontent.com/u/1561347?v=4)](https://github.com/vinicius73 "vinicius73 (1 commits)")[![mcmains](https://avatars.githubusercontent.com/u/1958721?v=4)](https://github.com/mcmains "mcmains (1 commits)")[![nicolasbinet](https://avatars.githubusercontent.com/u/867710?v=4)](https://github.com/nicolasbinet "nicolasbinet (1 commits)")[![CliffBrown](https://avatars.githubusercontent.com/u/3011622?v=4)](https://github.com/CliffBrown "CliffBrown (1 commits)")[![asmerkin](https://avatars.githubusercontent.com/u/488609?v=4)](https://github.com/asmerkin "asmerkin (1 commits)")

---

Tags

laraveleloquentlaravel5tagstagtaggingtaggedTaggable

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/qmagix-laravel-tagging/health.svg)

```
[![Health](https://phpackages.com/badges/qmagix-laravel-tagging/health.svg)](https://phpackages.com/packages/qmagix-laravel-tagging)
```

###  Alternatives

[rtconner/laravel-tagging

Use PHP traits to extend Laravel Eloquent Models to allow Tags. Models can be marked as Taggable.

8853.1M15](/packages/rtconner-laravel-tagging)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567714.4k4](/packages/cviebrock-eloquent-taggable)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2111.2M16](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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