PHPackages                             marc-coll/laravel-trix - 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. marc-coll/laravel-trix

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

marc-coll/laravel-trix
======================

trix editor for laravel inspired by ActionText for rails

3.1(5y ago)074MITPHPPHP ^7.1

Since Oct 26Pushed 5y agoCompare

[ Source](https://github.com/labdada/laravel-trix)[ Packagist](https://packagist.org/packages/marc-coll/laravel-trix)[ Docs](https://github.com/te7ahoudini/laravel-trix)[ RSS](/packages/marc-coll-laravel-trix/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (9)Used By (0)

[![](logo.svg)](logo.svg)

[![Releases](https://camo.githubusercontent.com/e9af02e8c00b80533580c1cf39a759a8dd0d183d7a6f1da4d0d9c95a64975eec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f546537612d486f7564696e692f6c61726176656c2d747269782e7376673f7374796c653d666c61742d737175617265)](https://github.com/Te7a-Houdini/laravel-trix/releases)[![Build Status](https://camo.githubusercontent.com/1349ec2f2a0e67512031b0655c1c7edd22cffcf0f1b1edcc5870ae85e02a0641/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f546537612d486f7564696e692f6c61726176656c2d747269782f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Te7a-Houdini/laravel-trix)[![StyleCI](https://camo.githubusercontent.com/f1fb9d128b1eaa99eed18bd497534c87841a87568afb15c3e8dd174c6e2f72da/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3231373730333430302f736869656c64)](https://github.styleci.io/repos/217703400)[![Code Quality](https://camo.githubusercontent.com/692308c511ad9b2a46faa9243b94d9fe755845c6cb90c67f9eccf2f4f0a3d4cf/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f546537612d486f7564696e692f6c61726176656c2d747269782e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Te7a-Houdini/laravel-trix/?branch=master)[![License](https://camo.githubusercontent.com/10ddcf9d2cc3ef196c173938102d3ddfcf7b9eb887e7ce3bd7d72f81b0671afd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f546537612d486f7564696e692f6c61726176656c2d747269782e7376673f7374796c653d666c61742d737175617265)](https://github.com/Te7a-Houdini/laravel-trix/blob/master/LICENSE.md)[![Downloads](https://camo.githubusercontent.com/85a44ff7e2253403166aeb4c13c5aa57f8c4ce1a8748ad35827be14008069598/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f546537612d486f7564696e692f6c61726176656c2d747269782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/te7a-houdini/laravel-trix)

Configurable [Basecamp Trix Editor](https://trix-editor.org/) delivered to your laravel application
---------------------------------------------------------------------------------------------------

[](#configurable-basecamp-trix-editor-delivered-to-your-laravel-application)

inspired by [Rails Action Text](https://edgeguides.rubyonrails.org/action_text_overview.html)

- [Installation](#installation)
- [Usage](#usage)
    - [Using @trix($model, $field, $config = \[\])](#using-@trix($model,-$field,-$config-=-%5B%5D))
    - [Storing Rich Text Fields](#storing-rich-text-fields)
    - [Render Trix For Existing Model](#render-trix-for-existing-model)
    - [Storing Attachment](#storing-attachment)
    - [Changing Storage Disk](#changing-storage-disk)
    - [Configuration Table](#configuration-table)
- [Testing](#testing)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require te7a-houdini/laravel-trix
```

Then publish the configurations and migrations:

```
php artisan vendor:publish --provider="Te7aHoudini\LaravelTrix\LaravelTrixServiceProvider"
```

After the migration has been published then run the migrations to create required tables:

```
php artisan migrate
```

then add `@trixassets` directive at the head tag of your html

```

        @trixassets

```

Usage
-----

[](#usage)

let's assume we have `Post model` &amp; want to add trix editor.

### Using @trix($model, $field, $config = \[\])

[](#using-trixmodel-field-config--)

you can use @trix directive inside any view to render trix editor.

```

        @trixassets

        @trix(\App\Post::class, 'content')

```

### Storing Rich Text Fields

[](#storing-rich-text-fields)

now lets try to store `content` rich text field when hitting submit button.

```

        @trixassets

            @csrf
            @trix(\App\Post::class, 'content')

```

first add `HasTrixRichText` trait to your model

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use Te7aHoudini\LaravelTrix\Traits\HasTrixRichText;

class Post extends Model
{
    use HasTrixRichText;

    protected $guarded = [];
}
```

then you can easily store any rich text fields by multiple ways:

```
Post::create(request()->all());

//storing must follow this convention (model lowered class name)-trixFields
Post::create([
    'post-trixFields' => request('post-trixFields'),
]);
```

### Render Trix For Existing Model

[](#render-trix-for-existing-model)

there's multiple ways to render trix for already existing model

```

@trix($post, 'content')

{!! $post->trix('content') !!} //must use HasTrixRichText trait in order for $model->trix() method work

{!! app('laravel-trix')->make($post, 'content') !!}
```

### Storing Attachment

[](#storing-attachment)

when uploading a file to trix editor. an ajax request is sent to `store_attachment_action` in `laravel-trix` config file. which uses [Laravel Storage](https://laravel.com/docs/master/filesystem#introduction) and then this action returns `url` if upload is success according to [Basecamp Trix api](https://github.com/basecamp/trix#storing-attached-files) .

the uploaded file will be stored in `trix_attachments` table as `pending` attachment.

once model is saved . all `pending` attachments will have `is_pending` column = `0`

so in order to make storing attachment very easy make sure to use `HasTrixRichText` trait in your model.

```
Post::create(request()->all());

//storing must follow this convention (model lowered class name)-trixFields
//and for attachment must follow attachment-(model lowered class name)-trixFields
Post::create([
    'post-trixFields' => request('post-trixFields'),
    'attachment-post-trixFields' => request('attachment-post-trixFields')
]);
```

### Changing Storage Disk

[](#changing-storage-disk)

you can change attachment storage disk from `laravel-trix` config file .

```
return [
    'storage_disk' => env('LARAVEL_TRIX_STORAGE_DISK', 'public'),

    'store_attachment_action' => Te7aHoudini\LaravelTrix\Http\Controllers\TrixAttachmentController::class . '@store',

    'destroy_attachment_action' => Te7aHoudini\LaravelTrix\Http\Controllers\TrixAttachmentController::class . '@destroy',
];
```

or if you want to change the storage disk for specific rich text field you can do that

```
@trix($post, 'content', ['disk' => 'local'])
```

### Configuration Table

[](#configuration-table)

if you want to hide buttons or toolbar you can do this. for more configuration refer to the table below.

```
@trix($post, 'content', [ 'hideButtonIcons' => ['attach', 'bold'] ])

@trix($post, 'content', [ 'hideTools' => ['text-tools'] ])
```

configurationtypevaluesdescriptionhideToolbarBooleanTrue or Falsehides the the toolbarhideToolsArray\['text-tools', 'block-tools', 'file-tools', 'history-tools'\]hides group of buttonshideButtonIconsArray\['attach', 'bold', 'italic', 'strike', 'link', 'heading-1', 'quote', 'code', 'bullet-list', 'number-list', 'decrease-nesting-level', 'increase-nesting-level'\]hides a single buttondiskString'local' or 's3' or 'any-disk'sets the attachment storage per fieldidString'any-value-you-want'the id of input which renders [trix. check this link](https://github.com/basecamp/trix#integrating-with-forms) . current id follows this convention `(model lowered class name)-field-modelId` like `post-content-1` or `post-content-new-model`containerElementStringvalid html tag like `span` or `div`default container tag is set to `span` you can change it as you want### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Ahmed Abd El Ftah](https://github.com/Te7a-Houdini)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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 ~55 days

Total

7

Last Release

2055d ago

Major Versions

1.1.0 → 2.0.02020-03-04

2.0.2 → v3.02020-09-10

PHP version history (2 changes)1.0.0PHP ^7.0

2.0.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/058fc6b3c7c93bcae40b9421d78148c322b99d529d8ad72e99c59c507de90c28?d=identicon)[marc-coll](/maintainers/marc-coll)

---

Top Contributors

[![amaelftah](https://avatars.githubusercontent.com/u/17250137?v=4)](https://github.com/amaelftah "amaelftah (14 commits)")[![marc-coll](https://avatars.githubusercontent.com/u/6703628?v=4)](https://github.com/marc-coll "marc-coll (3 commits)")[![AhmedHelalAhmed](https://avatars.githubusercontent.com/u/20116830?v=4)](https://github.com/AhmedHelalAhmed "AhmedHelalAhmed (1 commits)")[![intellow](https://avatars.githubusercontent.com/u/40676515?v=4)](https://github.com/intellow "intellow (1 commits)")[![kiritokatklian](https://avatars.githubusercontent.com/u/6556281?v=4)](https://github.com/kiritokatklian "kiritokatklian (1 commits)")

---

Tags

te7a-houdinilaravel-trix

### Embed Badge

![Health badge](/badges/marc-coll-laravel-trix/health.svg)

```
[![Health](https://phpackages.com/badges/marc-coll-laravel-trix/health.svg)](https://phpackages.com/packages/marc-coll-laravel-trix)
```

###  Alternatives

[te7a-houdini/laravel-trix

trix editor for laravel inspired by ActionText for rails

545170.4k2](/packages/te7a-houdini-laravel-trix)[vantran/lunar-calendar

Thư viện PHP Âm lịch Việt Nam

101.7k](/packages/vantran-lunar-calendar)

PHPackages © 2026

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