PHP code example of kfoobar / laravel-shortcode

1. Go to this page and download the library: Download kfoobar/laravel-shortcode library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kfoobar / laravel-shortcode example snippets


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

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

// 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!

use KFoobar\Shortcode\Traits\HasShortcode;

class MyModel extends Model
{
    use HasShortcode;

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

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

protected $shortcode = true;

protected $middlewareGroups = [
    'web' => [
        // other middleware
        \KFoobar\Shortcode\Middlware\ApplyShortcode::class,
    ],
bash
php artisan vendor:publish --tag=shortcode-config