PHPackages                             ps24love/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ps24love/shortcode

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

ps24love/shortcode
==================

06PHP

Since Jun 2Pushed 11y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel 4 - Simple Shortcode
============================

[](#laravel-4---simple-shortcode)

### Installation

[](#installation)

Open your composer.json file, and add the new required package.

```
  "ps24love/shortcode": "dev-master"

```

Next, open a terminal and run.

```
  composer update

```

After the composer updated. Add new service provider in app/config/app.php.

```
  'ps24love\Shortcode\ShortcodeServiceProvider'

```

Add new Facade alias.

```
'Shortcode'       => 'ps24love\Shortcode\Facades\Shortcode',
```

Done.

### Registering Shorcode

[](#registering-shorcode)

Using closure:

```
Shortcode::register('a', function($attr, $content = null, $name = null)
{
	$text = Shortcode::compile($content);
	return ''. $text .'';
});
```

Using class name.

```
class DivShortcode
{
  public function register($attr, $content = null, $name = null)
  {
  	$text = Shortcode::compile($content);
  	return ''. $text .'';
  }
}

Shortcode::register('div', 'DivShortcode');
```

Using class name with the specified method.

```
class HTMLShortcode
{
  public function img($attr, $content = null, $name = null)
  {
    $src = array_get($attr, 'src');
  	$text = Shortcode::compile($content);
  	return '';
  }
}

Shortcode::register('img', 'HTMLShortcode@img');
```

Using callback array.

```
class SpanShortcode
{

  public function div($attr, $content = null, $name = null)
  {
  	$text = Shortcode::compile($content);
  	return ''. $text .'';
  }
}

Shortcode::register('span', array('SpanShortcode', 'span'));
```

Using function name.

```
function smallTag($attr, $content = null, $name = null)
{
	$text = Shortcode::compile($content);
	return ''. $text .'';
}

Shortcode::register('small', 'smallTag');
```

### Compile

[](#compile)

```
$text = '[a href="#"]Click here[/a]';
echo Shortcode::compile($text);

$text = '
[a href="#"]
 [img src="http://placehold.it/140x140"]
 [small]This is small text[/small]
[/a]
';
echo Shortcode::compile($text);
```

### License

[](#license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![ps24love](https://avatars.githubusercontent.com/u/1007823?v=4)](https://github.com/ps24love "ps24love (6 commits)")

### Embed Badge

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

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

PHPackages © 2026

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