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

ActiveLibrary

waltersilvacruz/laravel-shortcodes
==================================

Wordpress like shortcodes for Laravel 5, 6, 7, 8, 9, 10 and 11 (fork of webwizo/laravel-shortcodes)

v1.0.22(1y ago)155MITPHPPHP ^7.2|^8.0|^8.1|^8.2|^8.3

Since May 24Pushed 1y agoCompare

[ Source](https://github.com/waltersilvacruz/laravel-shortcodes)[ Packagist](https://packagist.org/packages/waltersilvacruz/laravel-shortcodes)[ Docs](https://github.com/waltersilvacruz/laravel-shortcodes)[ RSS](/packages/waltersilvacruz-laravel-shortcodes/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (7)Versions (21)Used By (0)

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

[](#laravel-shortcodes)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8d4850c89b9f291dba3835aac5140c99e2a0bba3ed22ca52b3b59ebf918cfaf0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656277697a6f2f6c61726176656c2d73686f7274636f6465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webwizo/laravel-shortcodes)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/8bb185cc094ffc2ff749f9249c4e05367562e70372821b2d2dfacd57eb0bf39a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f77656277697a6f2f6c61726176656c2d73686f7274636f6465732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/webwizo/laravel-shortcodes)[![Coverage Status](https://camo.githubusercontent.com/a16874aedd7c71347eb8f6d53ad8fb78f907fcd5cdb5865775f3d1d4586e6e51/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f77656277697a6f2f6c61726176656c2d73686f7274636f6465732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/webwizo/laravel-shortcodes/code-structure)[![Quality Score](https://camo.githubusercontent.com/9b0de99eb0b8d494e06472bfe69a30b8565545e3f9bb9250eb48d32a36a0d21f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f77656277697a6f2f6c61726176656c2d73686f7274636f6465732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/webwizo/laravel-shortcodes)[![Total Downloads](https://camo.githubusercontent.com/19b933237a597968ddca3008fc31bc645137422c9cac164021ea24b561235586/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656277697a6f2f6c61726176656c2d73686f7274636f6465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webwizo/laravel-shortcodes)[![StyleCI](https://camo.githubusercontent.com/e87469197592d3098ca98996b2591a728ad1dea7dd2cb0f3c866bcb027dfa187/68747470733a2f2f7374796c6563692e696f2f7265706f732f35393530373239322f736869656c64)](https://styleci.io/repos/59507292)

WordPress like shortcodes for Laravel 5.x

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

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

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

If you are looking for Laravel 4.2, see:

Install
-------

[](#install)

Via Composer

```
$ composer require "webwizo/laravel-shortcodes:1.0.*"
```

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

Usage
-----

[](#usage)

```
Webwizo\Shortcodes\ShortcodesServiceProvider::class,
```

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

```
'Shortcode' => Webwizo\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

```
