PHPackages                             gornymedia/laravel-shortcodes - 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. gornymedia/laravel-shortcodes

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

gornymedia/laravel-shortcodes
=============================

Laravel shortcodes package

v1.5(11mo ago)2339.5k↓41.9%4MITPHP

Since Feb 22Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/gornymedia/laravel-shortcodes)[ Packagist](https://packagist.org/packages/gornymedia/laravel-shortcodes)[ RSS](/packages/gornymedia-laravel-shortcodes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Laravel-Shortcodes
==================

[](#laravel-shortcodes)

Laravel Shortcodes Package

Laravel compatibility
=====================

[](#laravel-compatibility)

LaravelShortcodes12.x1.511.x1.510.x1.49.x1.48.x1.47.x1.46.x1.45.8.x1.35.5.x1.25.4.x1.15.3.x1.15.2.x1.15.1.x1.05.0.x1.0Installation
============

[](#installation)

Require this package with Composer

```
composer require gornymedia/laravel-shortcodes 1.5
```

Add the service provider to `bootstrap/providers.php`

```
Gornymedia\Shortcodes\ShortcodesServiceProvider::class,
```

To use the facades, add this within the register method of `app/Providers/AppServiceProvider`

```
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Shortcode', \Gornymedia\Shortcodes\Facades\Shortcode::class);
```

Copy the package config to your local config with the publish command

```
php artisan vendor:publish --provider="Gornymedia\Shortcodes\ShortcodesServiceProvider"
```

Usage
=====

[](#usage)

Creating shortcodes
-------------------

[](#creating-shortcodes)

Inside an `app/Providers/AppServiceProvider` boot function you can create the shortcodes with attributes.

```
use Gornymedia\Shortcodes\Facades\Shortcode;

Shortcode::add('example', function($atts, $content, $name)
{
  $a = Shortcode::atts([
    'name' => $name,
    'foo' => 'something',
    ], $atts);

  return "foo = {$a['foo']}";
});

Usage : [example foo="something else"]
```

Include partial files in shortcode

```
use Gornymedia\Shortcodes\Facades\Shortcode;

Shortcode::add('widget', function($atts, $content, $name)
{
  $a = Shortcode::atts([
    'name' => $name,
    'foo' => 'something'
  ], $atts);

  $file = 'partials/' . $a['name'] ; // ex: resource/views/partials/ $atts['name'] .blade.php

  if (view()->exists($file)) {
    return view($file, $a);
  }
});

Usage : [widget name="maps"]
```

Compile shortcodes inside shortcode content

```
use Gornymedia\Shortcodes\Facades\Shortcode;

Shortcode::add('strong', function($atts, $content, $name) {
 $content = Shortcode::compile($content);

 return "$content";
});

Usage: [strong][example][/strong]
```

View rendering
--------------

[](#view-rendering)

### compileShortcodes()

[](#compileshortcodes)

To render the view and compile the Shortcodes:

```
return view('view')->compileShortcodes();
```

### stripShortcodes()

[](#stripshortcodes)

To render the view and remove the Shortcodes

```
return view('view')->stripShortcodes();
```

In the `config/gornymedia-laravel-shortcodes.php` file you can set the default mode (`null`, `compile` or `strip`).

The following example will compile shortcodes without using the `compileShortcodes()` method

```
return [
    'mode' => 'compile'
];
```

License
=======

[](#license)

This package is open-source software licensed under MIT License.

This package uses WordPress shortcodes methods. The license under which the WordPress software is released is the GPLv2 (or later).

Support
=======

[](#support)

Support me with any amount and help me develop.

[![](https://camo.githubusercontent.com/e1ff554a09e8e92bef25abc553ff05b88f45afd695877cf12f3a46558ef65b2e/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=S4RCAGKGXMK4U&source=url)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance50

Moderate activity, may be stable

Popularity38

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~749 days

Total

6

Last Release

354d ago

PHP version history (2 changes)v1.0PHP &gt;=5.4.0

v1.3PHP &gt;=7.1.3

### Community

Maintainers

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

---

Top Contributors

[![gornymedia](https://avatars.githubusercontent.com/u/9460661?v=4)](https://github.com/gornymedia "gornymedia (4 commits)")[![lucassmacedo](https://avatars.githubusercontent.com/u/3357243?v=4)](https://github.com/lucassmacedo "lucassmacedo (1 commits)")

---

Tags

laravelshortcodes

### Embed Badge

![Health badge](/badges/gornymedia-laravel-shortcodes/health.svg)

```
[![Health](https://phpackages.com/badges/gornymedia-laravel-shortcodes/health.svg)](https://phpackages.com/packages/gornymedia-laravel-shortcodes)
```

###  Alternatives

[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4205.3M84](/packages/livewire-volt)[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

97139.6k2](/packages/nickurt-laravel-akismet)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)[sbine/route-viewer

A Laravel Nova tool to view your registered routes.

57215.9k](/packages/sbine-route-viewer)[forxer/laravel-gravatar

A library providing easy gravatar integration in a Laravel project.

4235.6k](/packages/forxer-laravel-gravatar)

PHPackages © 2026

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