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

ActiveLibrary

kfoobar/laravel-shortcode
=========================

A versatile and easy-to-use shortcode manager for Laravel applications, offering a simple way to integrate and manage shortcodes within a Laravel project.

v1.0.3(8mo ago)042MITPHPPHP ^8.0

Since Jan 30Pushed 8mo ago1 watchersCompare

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

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

Shortcodes for Laravel
======================

[](#shortcodes-for-laravel)

A lightweight and flexible shortcode manager designed for Laravel 8–12.

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

[](#installation)

Install the package using Composer:

```
composer require kfoobar/laravel-shortcode
```

Settings
--------

[](#settings)

Publish the configuration file to customize settings:

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

Usage
-----

[](#usage)

### Adding Custom Shortcodes

[](#adding-custom-shortcodes)

Easily define custom shortcodes like this:

```
Shortcode::add('author', 'Joe Doe');
```

### Configuring Default Shortcodes

[](#configuring-default-shortcodes)

Use the shortcodes array in the config file to set default shortcodes:

```
'shortcodes' => [
    'author' => 'John Doe',
],
```

### Shortcode Formatting

[](#shortcode-formatting)

Shortcode keys are automatically transformed: they are converted to uppercase and wrapped with a character defined in the `wrapper` setting of your config file. The default wrapper character is `%`.

### Rendering Shortcodes

[](#rendering-shortcodes)

Obtain parsed content with various options:

```
// Standard Parsing
Shortcode::render($content);

// Markdown Conversion
Shortcode::markdown($content);

// Text Parsing (Stripping HTML)
Shortcode::text($content);
```

```
Shortcode::render('%YEAR% will be awesome!'); // 2024 will be awesome!
```

Within Blade templates, use the `@shortcode` directive:

```
@shortcode($content)
```

*Note: The Blade directive employs the render() method.*

Integrating with Models
-----------------------

[](#integrating-with-models)

Utilize the `HasShortcode` trait for automatic shortcode parsing:

```
use KFoobar\Shortcode\Traits\HasShortcode;

class MyModel extends Model
{
    use HasShortcode;

    // Specify attributes for parsing or use '*' for all
    protected $shortcodes = ['*'];
```

Automatic shortcode parsing is turned off by default to avoid conflicts with writing operations. This precaution ensures that routine create, update and delete actions proceed without unintentional interference from the shortcode processing mechanism.

### Enable With Code

[](#enable-with-code)

```
$model = (new MyModel)->withShortcode();
```

### Enable With Model Setting

[](#enable-with-model-setting)

Enable auto-parsing by default:

```
protected $shortcode = true;
```

### Enable With Middleware

[](#enable-with-middleware)

Enable auto-parsing for specific routes:

```
protected $middlewareGroups = [
    'web' => [
        // other middleware
        \KFoobar\Shortcode\Middlware\ApplyShortcode::class,
    ],
```

*The middleware automatically excludes non-read requests, AJAX requests, and Laravel Nova requests.*

Predefined Shortcodes
---------------------

[](#predefined-shortcodes)

These are the predefined shortcodes:

ShortcodeValue%YEAR%2024%MONTH%January%WEEK%3%DAY%Monday%DATE%2024-01-01%TIME%12:00%DOMAIN%project.test%APP-NAME%Laravel%APP-URL%Contributing
------------

[](#contributing)

Your contributions are highly appreciated.

License
-------

[](#license)

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

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance61

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~196 days

Total

4

Last Release

248d ago

PHP version history (2 changes)v1.0.0PHP ^8

v1.0.2PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![KFoobar](https://avatars.githubusercontent.com/u/420690?v=4)](https://github.com/KFoobar "KFoobar (8 commits)")

---

Tags

laravelcontent managementshortcode

### Embed Badge

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

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

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M253](/packages/cviebrock-eloquent-sluggable)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)

PHPackages © 2026

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