Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Mentions

Laravel Mentions Laravel Package

crixuamg/laravel-mentions

Add @mention support to Laravel apps: parse mentions from text, resolve them to Eloquent models, render linked usernames in Blade, and notify mentioned users through a simple, lightweight API.

View on GitHub
Deep Wiki
Context7

A package to parse @mentions from a text and mention the users with Laravel.

Frequently asked questions about Laravel Mentions
How do I install crixuamg/laravel-mentions in a Laravel app?
Install it with Composer using composer require crixuamg/laravel-mentions. On modern Laravel versions the service provider is registered automatically through package discovery, so no manual wiring is usually needed. If your app has package discovery disabled or you are on an older Laravel release, add the provider to your config/app.php providers array. Check the repository README for any publishable config or migration steps.
How does laravel-mentions parse @mentions out of a block of text?
You hand the package a string, such as a comment body or post content, and it extracts the @mention handles it finds. The result is the set of mentioned usernames that you can then resolve against your own data. This keeps parsing decoupled from storage, so you can use it on form input before saving. Exact pattern details and return types are documented in the repository README.
How do I resolve parsed mentions to Eloquent user models?
After parsing, you map each extracted handle to a record in your users table, typically by querying your User model on a username or handle column. The package is built to work with Eloquent models, so pointing it at your own model class fits naturally. Fetch all handles in a single whereIn query rather than one query per mention. Handles that do not match any row can simply be ignored or rendered as plain text.
Can I render mentions as linked usernames in Blade templates?
Yes. The package includes Blade rendering so parsed mentions become anchor tags pointing at user profiles instead of raw @text. You supply the URL structure, for example a route to your user profile page, and the package outputs the linked username inside your view. Always let Blade escape the username output, and use a trusted route helper or URL generator to build the href so user-supplied handles cannot inject markup.
How do I notify users who were mentioned in a comment or post?
The package exposes a simple API for notifying mentioned users, which you call after saving the content that contains the mentions. In practice you resolve the handles to user models, exclude the author, then dispatch a Laravel notification to each recipient. Because it uses Laravel's notification system, the same mention can trigger mail, database, or broadcast channels based on each user's preferences. Wrap this in a queued job if a post can mention many people.
Which Laravel versions does crixuamg/laravel-mentions support?
Version support is defined by the package's composer.json constraints, so check that file or the Packagist page before adding it to an older application. Confirm the required PHP version at the same time, since Laravel upgrades often raise the minimum PHP release. If your project is pinned to an older Laravel version, verify a matching package release exists or test on a branch first. Running composer require in a throwaway branch is the quickest way to surface conflicts.
How do I test mention parsing and notifications in my own test suite?
Unit test the parser with a variety of sample strings, including multiple mentions, repeated handles, and text with no mentions at all. Use model factories to create the users your handles should resolve to, then assert that the resolved collection contains exactly the expected records. For notifications, use Laravel's Notification::fake() and assert that the expected users were notified and the author was not. Feature tests covering the full store-then-notify flow catch integration issues cheaply.
What happens with @ symbols in email addresses or handles that do not exist?
Edge cases like email addresses, code snippets, and unknown handles depend on the parser's pattern, so test them against your real content before shipping. A common approach is to resolve only handles that match an existing user and leave everything else as literal text. Do not assume the parser strips or rewrites unmatched mentions automatically. Writing a short test case of tricky strings is the safest way to pin down the behaviour your app needs.
Is laravel-mentions safe and performant in production?
It is a lightweight package focused on parsing and resolving mentions, so most performance risk comes from how you use it rather than from the package itself. Resolve all handles in one query, eager load anything your notification needs, and queue mention notifications when a post can tag many users. On the security side, treat handles as untrusted input: escape them in Blade, validate length, and build profile URLs through route helpers instead of string concatenation. Cap the number of mentions accepted per post to avoid abuse.
What are the alternatives to laravel-mentions, and is it still maintained?
Alternatives include writing your own regex parser plus a Blade helper, which gives full control over the mention syntax and costs only a small amount of code, or using a general markdown or rich-text parser that handles mentions as one of its features. A dedicated package like this one saves time if you want parsing, Eloquent resolution, Blade rendering, and notifications in one place. Before adopting it, check the GitHub repository and Packagist release history for recent commits, open issues, and compatibility with your Laravel version, since small packages can go quiet over time.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo