PHP code example of trinityrank / shortcode

1. Go to this page and download the library: Download trinityrank/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/ */

    

trinityrank / shortcode example snippets


    

    namespace App\Providers;

    use Illuminate\Support\ServiceProvider;
    use Trinityrank\Shortcodes\Facades\Shortcode;

    class DateShortcodesServiceProvider extends ServiceProvider
    {
        public function boot()
        {
            Shortcode::enable();
        }

        public function register()
        {
            Shortcode::register('month', function ($atts, $content, $tag) {
                return date('F'); // Returns full month name (e.g., January)
            });

            Shortcode::register('year', function ($atts, $content, $tag) {
                return date('Y'); // Returns full month name (e.g., 2024)
            });
        }
    }

bash
    php artisan make:provider DateShortcodesServiceProvider