PHPackages                             rafaelbeckel/sirtrevor - 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. rafaelbeckel/sirtrevor

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

rafaelbeckel/sirtrevor
======================

Sir Trevor JS in Laravel 5 project

2.1.0(10y ago)034MITPHP

Since Feb 4Pushed 10y ago1 watchersCompare

[ Source](https://github.com/rafaelbeckel/Laravel-SirTrevor)[ Packagist](https://packagist.org/packages/rafaelbeckel/sirtrevor)[ RSS](/packages/rafaelbeckel-sirtrevor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (56)Used By (0)

Laravel-SirTrevorJS
===================

[](#laravel-sirtrevorjs)

Integrate the tool [Sir Trevor JS](http://madebymany.github.io/sir-trevor-js/) in a [Laravel 5](http://laravel.com) project.

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

[](#installation)

#### ========== WARNING!!! ===============

[](#-warning-)

I just cloned this repository for a personal project and in the next days I'll make some changes that may break things. **DO NOT USE IT IN PRODUCTION** (unless if you are me). I recommend using original author's repository instead (link below).

I plan to release a stable version with a different API in a near future, but right now I cannot tell exactly when I'll do it.

#### ====================================

[](#)

This package is available through `Packagist` and `Composer`.

> **For Laravel 5**, use the [branch master](https://github.com/caouecs/Laravel-SirTrevorJS/tree/master) : `"caouecs/sirtrevorjs": "~2.0"`

### Aliases

[](#aliases)

In your `app/config/app.php`, add in aliases :

```
'SirTrevorJs' => 'Caouecs\Sirtrevorjs\SirTrevorJs',
'STConverter' => 'Caouecs\Sirtrevorjs\SirTrevorJsConverter'

```

### Service Provider

[](#service-provider)

If you want to use routing, controllers, views directly in your project, in your `app/config/app.php`, add `"Caouecs\Sirtrevorjs\SirtrevorjsServiceProvider"` to your list of providers.

### thujohn/twitter

[](#thujohntwitter)

To get tweets, this project uses [twitter-l4](https://github.com/thujohn/twitter-l4), so you must have a valid developer account of Twitter and add config file of twitter-l4 :

```
php artisan config:publish thujohn/twitter

```

and add `"Thujohn\Twitter\TwitterServiceProvider"` to your list of providers in your `app/config/app.php`.

Configuration file
------------------

[](#configuration-file)

Next, you must migrate config :

```
php artisan vendor:publish caouecs/sirtrevorjs

```

After installation, the config file is located at *app/config/packages/caouecs/sirtrevorjs/sir-trevor-js.php*.

You can define :

- the path for image upload
- the route for upload image
- the route for tweet
- the path of Sir Trevor files
- the list of block types
- the language
- the paths for Eventable.js and Underscore.js
- the view
- configuration for blocks
    - soundcloud
    - gettyimages
- etc...

SirTrevorJs class
-----------------

[](#sirtrevorjs-class)

### Assets

[](#assets)

For stylesheets :

```
SirTrevorJs::stylesheets()

```

For scripts, in your Blade files :

```
SirTrevorJs::scripts()

```

### Fix for image block

[](#fix-for-image-block)

Function to fix a problem with image block when you add a new image :

```
$text = SirTrevorJs::transformText($text);

```

### Find first image

[](#find-first-image)

Get first image in text with `findImage` method :

```
string SirTrevorJS::findImage(string $text);

```

In return, you have url of image or empty string.

### Find elements by blocktypes

[](#find-elements-by-blocktypes)

Get all elements in text, in specified blocktype with `find` method :

```
mixed SirTrevorJS::find(string $text, string $blocktype [, string $output = "json"])

```

In return, you can have :

- array, if you choose "array" for $output
- json, if you choose "json" for $output
- false, if the script doesn't find an occurence of blocktype

SirTrevorJsController
---------------------

[](#sirtrevorjscontroller)

This class proposes two things :

- upload image where you want
- get tweets

### Upload image

[](#upload-image)

This project proposes a system for upload image, nothing to configure, just the `directory_upload` value in config file.

```
"directory_upload" => "img/uploads"

```

The uploader is in *SirTrevorJsController* class, and the project has a *route.php* file for it.

```
Route::any("/sirtrevorjs/upload", array("uses" => "SirTrevorJsController@upload"));

```

### Tweet

[](#tweet)

This project proposes a system to get tweets. I use [twitter-l4](https://github.com/thujohn/twitter-l4) project.

The installation of twitter-l4 is done by Composer, but you need to configure it ( see [Instructions](https://github.com/thujohn/twitter-l4/blob/master/README.md)).

The tweet converter is in *SirTrevorJsController* class, and the project has a *route.php* file for it.

```
Route::any("/sirtrevorjs/tweet", array("uses" => "SirTrevorJsController@tweet"));

```

SirTrevorJsConverter class (or STConverter class)
-------------------------------------------------

[](#sirtrevorjsconverter-class-or-stconverter-class)

Convert text from Sir Trevor Js to html :

```
$convert = new STConverter();
$convert->toHtml($text)

```

Or via SirTrevorJS class :

```
{{ SirTrevorJs::render($text) }}

```

For the moment, the code can convert :

- blockquote / quote
- embedly card
- [facebook post](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/facebook.js)
- [getty images](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/gettyimage.js)
- heading
- image
    - basic version
    - [version with caption](https://github.com/neyre/sir-trevor-wp/blob/master/custom-blocks/ImageCaption.js)
- [issuu](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/issuu.js)
- [pinterest](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/pinterest.js)
- [sketchfab](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/sketchfab.js)
- [slideshare](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/slideshare.js)
- [soundcloud](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/soundcloud.js)
- [spotify](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/spotify.js)
- text with Markdown
- tweet
- unordered list
- [video](https://github.com/caouecs/SirTrevorJS-blocks/blob/master/blocks/video.js)
    - aol
    - canal plus
    - daily mail uk
    - dailymotion
    - france tv
    - global news
    - livestream
    - metacafe
    - metatube
    - mlb
    - nbc bay area
    - nhl
    - ooyala
    - redtube
    - ustream (live and recorded)
    - veoh
    - vevo
    - vimeo
    - vine
    - wat
    - yahoo
    - youtube
    - zoomin.tv
    - video with caption

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% 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 ~11 days

Total

51

Last Release

3922d ago

Major Versions

1.4.13 → 2.0.02015-04-05

1.4.14 → 2.0.12015-05-19

1.4.15 → 2.0.22015-05-19

1.4.16 → 2.0.42015-06-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4ce990e2dfc9042a32509ba87f0747dbba51b1287623304f2b6df49424e9da9?d=identicon)[rafaelbeckel](/maintainers/rafaelbeckel)

---

Top Contributors

[![caouecs](https://avatars.githubusercontent.com/u/447849?v=4)](https://github.com/caouecs "caouecs (130 commits)")[![rafaelbeckel](https://avatars.githubusercontent.com/u/28917?v=4)](https://github.com/rafaelbeckel "rafaelbeckel (11 commits)")[![Zae](https://avatars.githubusercontent.com/u/96126?v=4)](https://github.com/Zae "Zae (2 commits)")

---

Tags

laravellpmsir trevor js

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rafaelbeckel-sirtrevor/health.svg)

```
[![Health](https://phpackages.com/badges/rafaelbeckel-sirtrevor/health.svg)](https://phpackages.com/packages/rafaelbeckel-sirtrevor)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M685](/packages/barryvdh-laravel-ide-helper)[caouecs/sirtrevorjs

Sir Trevor JS in Laravel project

5421.6k](/packages/caouecs-sirtrevorjs)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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