PHPackages                             murdercode/laravel-shortcode-plus - 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. murdercode/laravel-shortcode-plus

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

murdercode/laravel-shortcode-plus
=================================

A package that allows you to use custom shortcodes

v5.3.1(9mo ago)55482[2 PRs](https://github.com/murdercode/laravel-shortcode-plus/pulls)MITPHPPHP ^8.1|^8.2|^8.3|^8.4CI passing

Since Oct 30Pushed 9mo agoCompare

[ Source](https://github.com/murdercode/laravel-shortcode-plus)[ Packagist](https://packagist.org/packages/murdercode/laravel-shortcode-plus)[ Docs](https://github.com/murdercode/laravel-shortcode-plus)[ RSS](/packages/murdercode-laravel-shortcode-plus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (142)Used By (0)

[![Logo Laravel Shortcode Plus](https://github.com/murdercode/laravel-shortcode-plus/raw/HEAD/art/laravel-shortcode-logo.svg)](https://github.com/murdercode/laravel-shortcode-plus/raw/HEAD/art/laravel-shortcode-logo.svg)

[![Latest Version on Packagist](https://camo.githubusercontent.com/87c106767d6ead736e64b8f17cf87fd577602f464eaa35827eca75921a5766b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7572646572636f64652f6c61726176656c2d73686f7274636f64652d706c75732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/murdercode/laravel-shortcode-plus)[![GitHub Tests Action Status](https://camo.githubusercontent.com/6959b122b6e992b9f216f8c7e607feff104d19452b103dd50bbb9e1b0232d2b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7572646572636f64652f6c61726176656c2d73686f7274636f64652d706c75732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d70657374)](https://github.com/murdercode/laravel-shortcode-plus/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub PHPStan](https://camo.githubusercontent.com/e910a2c71551b51afed33f3edce2143c15f08266e0a4eba443d818c3778c28fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7572646572636f64652f6c61726176656c2d73686f7274636f64652d706c75732f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e)](https://github.com/murdercode/laravel-shortcode-plus/actions?query=workflow%3Aphpstan+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/6a7635300269aefc4132b36ae2fad3a1d197bc9dd45986aab992c0329ae5de03/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7572646572636f64652f6c61726176656c2d73686f7274636f64652d706c75732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d70696e74)](https://github.com/murdercode/laravel-shortcode-plus/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Maintainability](https://camo.githubusercontent.com/846f204541e802c23284ff06ee1a682da549e51ffa6205c3cd35ddd66e6a991f/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f65626631303033383232626165646535363536372f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/murdercode/laravel-shortcode-plus/maintainability)[![Test Coverage](https://camo.githubusercontent.com/a3928cad582d519f404d03c3fc4a0f24a6cefbe28009101c03807ecf1ead0c9a/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f65626631303033383232626165646535363536372f746573745f636f766572616765)](https://codeclimate.com/github/murdercode/laravel-shortcode-plus/test_coverage)[![License Mit](https://camo.githubusercontent.com/b3b89520b53d06cd919b8156fa18efa8b86e5498d0989dc1ccc1568e14ede1f1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d7572646572636f64652f6c61726176656c2d73686f7274636f64652d706c7573)](https://camo.githubusercontent.com/b3b89520b53d06cd919b8156fa18efa8b86e5498d0989dc1ccc1568e14ede1f1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d7572646572636f64652f6c61726176656c2d73686f7274636f64652d706c7573)[![Total Downloads](https://camo.githubusercontent.com/ab66147704865a972bab46025cf76dbadac49905aa66fa34fcd947bc1c3bab59/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7572646572636f64652f6c61726176656c2d73686f7274636f64652d706c75732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/murdercode/laravel-shortcode-plus)

---

Why Shortcode+?
---------------

[](#why-shortcode)

This package allows you to use shortcodes in your application, like a Wordpress / BBS style websites.

In our days, shortcodes are a great way to preserve the integrity of the data within the content published on our site (such as a blog or forum) without risking having to rewrite the format each time.

With Laravel Shortcode+ we have the ability to turn a standard shortcode into a dynamic asset that can update over time (new HTML standards, cookie consent, AMP versions, and more)!

**Warning: this is a very opinionated package and it's not intended to be multi-purpose.**

How it Works
------------

[](#how-it-works)

For example, you can use the following shortcode to embed a Youtube video:

```
[youtube url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"]
```

This will be rendered as:

```

```

As you can see, we don't just generate an iframe but make it accessible, performant and in line with the best SEO practices around.

---

Requirements
------------

[](#requirements)

Package VersionRequirementVersion5.x.xLaravel10.x or 11.x5.x.xNova4.xdev-beta-laravel-12Laravel12.xdev-beta-laravel-12Nova5.xInstallation
------------

[](#installation)

You can install the package via composer:

```
composer require murdercode/laravel-shortcode-plus
```

You can use shortcodes CSS publishing the assets:

```
php artisan vendor:publish --tag="shortcode-plus-assets"
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="shortcode-plus-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="shortcode-plus-config"
```

If you want to upgrade every time your assets, add in your composer.json:

```
    "scripts": {
"post-update-cmd": [
"@php artisan vendor:publish --tag=shortcode-plus-assets --ansi --force",
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="shortcode-plus-views"
```

Usage
-----

[](#usage)

Laravel Shortcode Plus is shipped with a default CSS and JS for a better user experience. You can add on **resources/css/app.css** the CSS files:

```
@import url("/public/vendor/shortcode-plus/app.css");
```

and in **resources/js/app.js** the JS files:

```
import '/public/vendor/shortcode-plus/app2.js';
```

Now you can parse your source as follows:

```
use Murdercode\LaravelShortcodePlus\Facades\LaravelShortcodePlus;

$html = "I want to parse this twitter tag: [twitter url=\"https://twitter.com/elonmusk/status/1585841080431321088\"]";
return LaravelShortcodePlus::source($html)->parseAll();
```

### Use Iubenda Cookie

[](#use-iubenda-cookie)

Add in your iubenda cookie script the following code: (/organisms/cookie-solution.blade.php)

```
if (purposeId === "3") {
    var elements = document.getElementsByClassName('shortcode_nocookie');
    for (var i = 0; i < elements.length; i++) {
        elements[i].style.display = 'none';
    }
}
```

#### Use Paywall with Iubenda Cookie

[](#use-paywall-with-iubenda-cookie)

In config, set `cookiePaywall` to `true`

In your iubenda cookie script, add the following code: (/organisms/cookie-solution.blade.php)

```

    function manageShortcodePaywall() {
        const shortcodesWithPaywall = document.querySelectorAll('.shortcode_with_paywall');
        const paywalls = document.querySelectorAll('.shortcode_paywall');

        shortcodesWithPaywall.forEach(shortcode => {
            if (_iub.cs.api.isConsentGiven()) {
                shortcode.style.display = 'block';
                paywalls.forEach(paywall => paywall.style.display = 'none');
            } else {
                shortcode.style.display = 'none';
                paywalls.forEach(paywall => paywall.style.display = 'block');
            }
        });
    }

    var _iub = _iub || [];
```

```
_iub.csConfiguration.callback.onPreferenceExpressed = manageShortcodePaywall;
_iub.csConfiguration.callback.onReady = manageShortcodePaywall;
```

```

    var paywallPrefBtn = document.querySelector('.shortcode_paywall button');
    paywallPrefBtn.addEventListener('click', function(ev) {
        ev.preventDefault();
        _iub.cs.api.acceptAll();
    });

```

### Indexing feature

[](#indexing-feature)

If you want to use the `[index]` shortcode, you can add the `withAutoHeadingIds()` method to your source **before**parsing it. It will add an automatic ID to every headline (h2, h3, h4 etc...) in your source:

```
return LaravelShortcodePlus::source($html)->withAutoHeadingIds()->parseAll();
```

This will add an ID to every heading (h2, h3, h4 etc...) in your source.

Parsers
-------

[](#parsers)

Here is the list of the available parsers:

ShortcodeDescriptionParametersExample`[twitter]  `Get a Twitter card`url``[twitter url="https://twitter.com/elonmusk/status/1585841080431321088"]``[bluesky]  `Get a BlueSky card`url``[bluesky url="https://bsky.app/profile/adamparkhomenko.bsky.social/post/3liz5p73u6k2f"]``[youtube]`Get a Youtube (light) player`url``[youtube url="https://www.youtube.com/watch?v=9bZkp7q19f0"]``[spotify]`Get a Spotify player`url` or `uri``[spotify url="https://open.spotify.com/track/2TpxZ7JUBn3uw46aR7qd6V"]``[faq]`Create a `` tag with embedded content`title``[faq title="What is the answer to the ultimate question?"]42[/faq]``[spoiler]`Create a `` tag with embedded content`title``[spoiler title="Spoiler"]This is hidden content[/spoiler]``[facebook]`Get a Facebook card`url``[facebook url="https://www.facebook.com/elonmusk/posts/10157744420210129"]``[instagram]`Get a Instagram card`url``[instagram url="https://www.instagram.com/p/CApQfIjBGxC/"]``[image]`Create an image with `Image::class` model`id`, `caption` (optional)`[image id="123"]``[gallery]`Create a gallery image with `Image::class` model`title`, `images`Single or multiple images: `[gallery title="Gallery title here" images="1"]` or `[gallery title="Gallery title here" images="1,2,3"]``[photo]`Create a gallery image with `[Nova Media Hub](https://github.com/outl1ne/nova-media-hub)` model`didascalia` `effect`(optional) `link`(optional) `shape`(optional)Single or multiple images: `\[photo didascalia="Gallery title here" id="1,2,3"\] Effect \[photo id="1,2,3" effect="carousel - juxtapose - gallery-flex" link="https://..." shape="default`[leggianche]`Create a Read more div, based on `Article` or `Post` model`id``[leggianche id="1"]``[distico]`Create a side text block, based on `Article` or `Post` model`id``[distico id="1"]``[button]`Create a button that links to an URL`link`, `label`, `level (optional)``[button link="https://www.google.com" label="Google" level="primary/secondary"]``[tmdb]`Create a TMDB card`type`, `id``[tmdb type="movie/tv" id="123"]``[widgetbay]`Create a Widgetbay iframe`id (optional)`, `link (optional)`, `forceLink (optional)`, `title (optional)``[widgetbay id="1"]` `[widgetbay title="Product Title" link="https://www.amazon.it/product?tag="41515&subtag="5151"..."]``[index]`Create an automatic index based on Heading (h2, h3, h4 etc...)none`[index]``[trivia]`Create a trivia`id``[trivia id="1"]`### Note for Facebook

[](#note-for-facebook)

Please remember to call the SDK before ``:

```

```

### Note for Twitter

[](#note-for-twitter)

Please remember to call the SDK before ``:

```

    window.twttr = (function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0],
            t = window.twttr || {};
        if (d.getElementById(id)) return t;
        js = d.createElement(s);
        js.id = id;
        js.src = "https://platform.twitter.com/widgets.js";
        fjs.parentNode.insertBefore(js, fjs);

        t._e = [];
        t.ready = function (f) {
            t._e.push(f);
        };

        return t;
    }(document, "script", "twitter-wjs"));

```

### Note for Reddit

[](#note-for-reddit)

Please remember to call the SDK before ``:

```

```

### Note for Justwatch

[](#note-for-justwatch)

Please remember to call the SDK before ``:

```

```

### Note for Parse links

[](#note-for-parse-links)

Please remember to add in config file the links to parse:

```
    'linksToParse' => [
        'sponsored' => [
            '#https://www\\.amazon\\.[A-Za-z]+#i',
            '#https://www\\.ebay\\.[A-Za-z]+#i',
            'https://www.instant-gaming.com',
        ],
        'dofollow' => [
            'https://forum.tomshw.it/',
        ],
        'nofollow' => [
            'https://www.youtube.com',
            'https://multiplayer.it',
            'https://www.everyeye.it',
        ],
    ],
```

You can use a regex or a string to parse the links.

And, when parse your content, you can use forceRel():

```
    $content = LaravelShortcodePlus::source($content)
        ->forceRel()
        ->parseAll();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stefano Novelli](https://github.com/murdercode)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance55

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 50.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 ~8 days

Total

125

Last Release

299d ago

Major Versions

v0.0.5 → v1.0.02022-11-02

v1.2.5 → v2.0.02023-02-13

v2.1.8 → v3.0.02023-08-23

v3.0.12 → v4.0.02023-10-30

v4.2.5 → v5.0.02024-04-30

PHP version history (4 changes)v0.0.1PHP ^8.1

v2.0.2PHP ^8.1|^8.2

v5.0.0PHP ^8.1|^8.2|^8.3

v5.3.0PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/907d738d7cdaba6d5ecad8ed396c7fc93e3afba674b2d2288fd218663faed501?d=identicon)[murdercode](/maintainers/murdercode)

---

Top Contributors

[![murdercode](https://avatars.githubusercontent.com/u/7630252?v=4)](https://github.com/murdercode "murdercode (374 commits)")[![Claudio-Emmolo](https://avatars.githubusercontent.com/u/113107618?v=4)](https://github.com/Claudio-Emmolo "Claudio-Emmolo (295 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (26 commits)")[![DispatchCode](https://avatars.githubusercontent.com/u/4256708?v=4)](https://github.com/DispatchCode "DispatchCode (23 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (19 commits)")

---

Tags

laravelphpshortcodeslaravelshortcodesembedshortcodemurdercodelaravel-shortcode-plus

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/murdercode-laravel-shortcode-plus/health.svg)

```
[![Health](https://phpackages.com/badges/murdercode-laravel-shortcode-plus/health.svg)](https://phpackages.com/packages/murdercode-laravel-shortcode-plus)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[maestroerror/laragent

Power of AI Agents in your Laravel project

630106.4k](/packages/maestroerror-laragent)[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[spatie/laravel-rdap

Perform RDAP queries in a Laravel app

72108.3k2](/packages/spatie-laravel-rdap)

PHPackages © 2026

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