DEV.co
Open-Source Databases · spatie

laravel-tags

Laravel Tags is a PHP package that adds tagging functionality to Laravel applications. It allows you to attach multiple tags to Eloquent models with support for tag types, translations, and sorting.

Source: GitHub — github.com/spatie/laravel-tags
1.7k
GitHub stars
285
Forks
PHP
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryspatie/laravel-tags
Ownerspatie
Primary languagePHP
LicenseMIT — OSI-approved
Stars1.7k
Forks285
Open issues0
Latest release4.12.0 (2026-06-20)
Last updated2026-06-26
Sourcehttps://github.com/spatie/laravel-tags

What laravel-tags is

A Laravel/Eloquent trait-based package providing many-to-many tagging via a pivot table. Includes query builders for filtering by tags, slug generation, tag type segregation, multi-language support via translation attributes, and order manipulation.

Quickstart

Get the laravel-tags source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/spatie/laravel-tags.gitcd laravel-tags# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Content Management Systems

Tag blog posts, articles, or news items for categorization, search, and discovery. The translation support enables multilingual content platforms.

Multi-type Categorization

Organize models by multiple independent tag hierarchies (e.g., 'categories', 'topics', 'authors') simultaneously on the same model.

Faceted Search & Filtering

Build tag-based query filters (withAnyTags, withAllTags, withoutTags) for user-facing search and browsing interfaces.

Implementation considerations

  • Add HasTags trait to target Eloquent model; run published migrations to create tags and taggables pivot tables.
  • Configure the optional config file to customize slug generation; defaults to Laravel's Str::slug helper.
  • Test tag queries (withAnyTags, withAllTags, withoutTags) against your data volume to ensure acceptable query performance.
  • Plan multi-language support upfront using setTranslation and tagsTranslated() methods if content is multilingual.
  • Document tag type naming conventions within your team to avoid accidental collisions across feature areas.

When to avoid it — and what to weigh

  • Hierarchical/Tree Taxonomies — This package handles flat tags only. If you need parent-child relationships, categories with levels, or tree structures, choose a different solution.
  • Non-Laravel or Legacy Frameworks — Requires Laravel 8+ and PHP 8+. Not compatible with older versions or non-Laravel applications.
  • Non-JSON-capable Databases — The package requires databases with JSON field support and MySQL-compatible functions. Legacy databases without JSON may not work.
  • High-volume Tag Performance Optimization — No mention of query optimization, caching strategies, or performance tuning for millions of tags or complex filtering at scale.

License & commercial use

MIT License permits commercial use, modification, and distribution with minimal restrictions. Full legal permissiveness under OSI-approved MIT terms.

MIT is a permissive OSI-approved license allowing unrestricted commercial use, including closed-source derivatives. No license fees or attribution requirement (though the package authors request a postcard if used in production). Suitable for proprietary Laravel applications.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

No known vulnerabilities reported (zero open issues). Dedicated security contact ([email protected]) available for disclosures. Standard practices: validate tag input server-side, ensure database credentials are protected, and review any custom slug generation logic. No penetration test data or security audit results provided in public data.

Alternatives to consider

Cviebrock/eloquent-taggable

Alternative Laravel tagging package; consider if you need different API, maintenance profile, or specific feature set not in laravel-tags.

Waavi/serializable

Lightweight serialization for Eloquent; may suffice for simple tag-like metadata without a dedicated tagging package.

Custom many-to-many pivot table

Build your own tagging via Laravel's hasMany/belongsToMany if you need full control and minimal dependencies.

Software development agency

Build on laravel-tags with DEV.co software developers

Evaluate laravel-tags for content categorization, search filtering, and multilingual tagging. If you need hierarchical taxonomies or non-Laravel frameworks, explore alternatives first.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

laravel-tags FAQ

Can I use this with non-Laravel PHP applications?
No. This package is built exclusively for Laravel 8+ with PHP 8+. It leverages Laravel's Eloquent ORM, migrations, and service provider architecture.
Do tags support hierarchies or parent-child relationships?
No. This package implements flat tagging only. Multiple tag types can segment tags logically, but there is no tree structure. For hierarchies, use a different solution or build custom parent references.
Is translation support automatic or must I manually set translations?
Manual. Use setTranslation('name', locale, value) to add translations per tag. The tagsTranslated() method retrieves tags with translated properties. No automatic i18n detection is built in.
What performance considerations exist for large datasets?
Not clearly stated. Test query performance (withAnyTags, withAllTags) with your typical tag counts. No benchmarks, indexing guidance, or caching strategies are documented.

Software developers & web developers for hire

DEV.co helps companies turn open-source tools like laravel-tags into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source databases stack.

Ready to Add Tagging to Your Laravel App?

Evaluate laravel-tags for content categorization, search filtering, and multilingual tagging. If you need hierarchical taxonomies or non-Laravel frameworks, explore alternatives first.