trinityrank / shortcode
Laravel Shortcodes
v1.2.3
2024-03-26 14:18 UTC
Requires
- php: ^7.4|^8.0
README
Installation
Step 1: Install package
To get started with Laravel Shortcodes, use Composer command to add the package to your composer.json project's dependencies:
composer require trinity-rank/shortcode
Step 2:
php artisan make:provider DateShortcodesServiceProvider
After creating ServiceProvider
<?php 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) }); } }
You can now use shortcodes for month and year like this:
[month] [year]