PHPackages                             te7a-houdini/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. [Templating &amp; Views](/categories/templating)
4. /
5. te7a-houdini/laravel-trix

ActiveLibrary[Templating &amp; Views](/categories/templating)

te7a-houdini/laravel-trix
=========================

trix editor for laravel inspired by ActionText for rails

3.1.0(1y ago)546181.9k↓16.1%52[33 issues](https://github.com/amaelftah/laravel-trix/issues)[2 PRs](https://github.com/amaelftah/laravel-trix/pulls)2MITPHPPHP ^7.1|^8.0CI failing

Since Oct 26Pushed 1y ago10 watchersCompare

[ Source](https://github.com/amaelftah/laravel-trix)[ Packagist](https://packagist.org/packages/te7a-houdini/laravel-trix)[ Docs](https://github.com/te7ahoudini/laravel-trix)[ RSS](/packages/te7a-houdini-laravel-trix/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (2)

[![](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') !!}
```

### Render Html For Existing Model

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

You can render the html content for already existing model

```

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

### 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'])
```

### Deleting Rich Text Field and Attachments

[](#deleting-rich-text-field-and-attachments)

you can remove related rich text fields and attachments on a model deleting:

```
class Post extends Model
{
    use HasTrixRichText;

    protected $guarded = [];

    protected static function boot()
    {
        parent::boot();

        static::deleted(function ($post) {
            $post->trixRichText->each->delete();
            $post->trixAttachments->each->purge();
        });
    }
}
```

### 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

52

—

FairBetter than 96% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity55

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 57.7% 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 ~149 days

Recently: every ~193 days

Total

14

Last Release

501d ago

Major Versions

1.1.0 → 2.0.02020-03-04

2.0.9 → 3.0.02024-03-13

PHP version history (3 changes)1.0.0PHP ^7.0

2.0.0PHP ^7.1

2.0.5PHP ^7.1|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef00b962479d759ffb75fb1f9e8dc02211d0bed49cb26bac0c650b81da0a1001?d=identicon)[Te7a-Houdini](/maintainers/Te7a-Houdini)

---

Top Contributors

[![amaelftah](https://avatars.githubusercontent.com/u/17250137?v=4)](https://github.com/amaelftah "amaelftah (15 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![Donotavio](https://avatars.githubusercontent.com/u/13056422?v=4)](https://github.com/Donotavio "Donotavio (1 commits)")[![dragomano](https://avatars.githubusercontent.com/u/229402?v=4)](https://github.com/dragomano "dragomano (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)")[![pitchayakit](https://avatars.githubusercontent.com/u/17026022?v=4)](https://github.com/pitchayakit "pitchayakit (1 commits)")[![AhmedHelalAhmed](https://avatars.githubusercontent.com/u/20116830?v=4)](https://github.com/AhmedHelalAhmed "AhmedHelalAhmed (1 commits)")[![teodoriu](https://avatars.githubusercontent.com/u/11290723?v=4)](https://github.com/teodoriu "teodoriu (1 commits)")[![diogogomeswww](https://avatars.githubusercontent.com/u/11543163?v=4)](https://github.com/diogogomeswww "diogogomeswww (1 commits)")

---

Tags

laravelphptrixtrix-editorwysiwygte7a-houdinilaravel-trix

### Embed Badge

![Health badge](/badges/te7a-houdini-laravel-trix/health.svg)

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

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3417.0k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

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