PHPackages                             uzwebline/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. uzwebline/laravel\_shortcodes

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

uzwebline/laravel\_shortcodes
=============================

Wordpress like shortcodes for Laravel 5.x

1.0.0(7y ago)210MITPHPPHP ~7.0

Since Jun 28Pushed 7y ago1 watchersCompare

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

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

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

[](#laravel-shortcodes)

[![Latest Version on Packagist](https://camo.githubusercontent.com/adf3ff03a4e1ea45cf44b7d3d7d88bd03bd54d94b2e314f40aed6a71d2c34060/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f757a7765626c696e652f6c61726176656c5f73686f7274636f6465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/uzwebline/laravel_shortcodes)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/fa001d936af55c615902445943329da602a4a956b205b3942891e1bd92ff5902/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f757a7765626c696e652f6c61726176656c5f73686f7274636f6465732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/uzwebline/laravel_shortcodes)[![Coverage Status](https://camo.githubusercontent.com/37d00db784ce3f4f6dd4dcc66bcb545cff7c8ebdd35eab6bdf9c56a0af0ed322/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f757a7765626c696e652f6c61726176656c5f73686f7274636f6465732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/uzwebline/laravel_shortcodes/code-structure)[![Quality Score](https://camo.githubusercontent.com/ca7161089c8a22c889d466e5c6c5c92a29e679e42641d7aab6456d6bac12b4c0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f757a7765626c696e652f6c61726176656c5f73686f7274636f6465732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/uzwebline/laravel_shortcodes)[![Total Downloads](https://camo.githubusercontent.com/5496bf35d6bad9a75d0c45132afb2b0818fca513ed3bdae8ecbff29c213a039a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f757a7765626c696e652f6c61726176656c5f73686f7274636f6465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/uzwebline/laravel_shortcodes)[![StyleCI](https://camo.githubusercontent.com/e87469197592d3098ca98996b2591a728ad1dea7dd2cb0f3c866bcb027dfa187/68747470733a2f2f7374796c6563692e696f2f7265706f732f35393530373239322f736869656c64)](https://styleci.io/repos/59507292)

WordPress like shortcodes for Laravel 5.x based on webwizo/laravel-shortcodes see:

```
[b class="bold"]Bold text.[/b]

[tabs]
  [tab]Tab 1[/tab]
  [tab]Tab 2[/tab]
[/tabs]

[user id="1" display="name"]
```

Install
-------

[](#install)

Via Composer

```
$ composer require "uzwebline/laravel_shortcodes:1.0.*"
```

After updating composer, add the ServiceProvider to the providers array in `config/app.php`

Usage
-----

[](#usage)

```
Uzwebline\Shortcodes\ShortcodesServiceProvider::class,
```

You can use the facade for shorter code. Add this to your aliases:

```
'Shortcode' => Uzwebline\Shortcodes\Facades\Shortcode::class,
```

The class is bound to the ioC as `shortcode`

```
$shortcode = app('shortcode');
```

Usage
=====

[](#usage-1)

### withShortcodes()

[](#withshortcodes)

To enable the view compiling features:

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

This will enable shortcode rendering for that view only.

### Enable through class

[](#enable-through-class)

```
Shortcode::enable();
```

### Disable through class

[](#disable-through-class)

```
Shortcode::disable();
```

### Disabling some views from shortcode compiling

[](#disabling-some-views-from-shortcode-compiling)

With the config set to true, you can disable the compiling per view.

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

Default compiling
-----------------

[](#default-compiling)

To use default compiling:

```
Shortcode::compile($contents);
```

### Strip shortcodes from rendered view.

[](#strip-shortcodes-from-rendered-view)

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

Strip shortcode through class
-----------------------------

[](#strip-shortcode-through-class)

```
Shortcode::strip($contents);
```

Registering new shortcodes
--------------------------

[](#registering-new-shortcodes)

Create a new ServiceProvider where you can register all the shortcodes.

```
php artisan make:provider ShortcodesServiceProvider
```

After defining shortcodes, add the ServiceProvider to the providers array in `config/app.php`

Usage
-----

[](#usage-2)

```
App\Providers\ShortcodesServiceProvider::class,
```

### Callback

[](#callback)

Shortcodes can be registered within ShortcodesServiceProvider with a callback:

```
php artisan make:provider ShortcodesServiceProvider
```

ShortcodesServiceProvider.php Class File

```
