@@ -27,7 +27,7 @@ If you are looking for Laravel 4.2, see: https://github.com/patrickbrouwers/Lara
2727
2828Via Composer
2929
30- ``` bash
30+ ``` bash
3131$ composer require " webwizo/laravel-shortcodes:1.0.*"
3232```
3333
@@ -107,7 +107,7 @@ Shortcode::strip($contents);
107107
108108Create a new ServiceProvider where you can register all the shortcodes.
109109
110- ``` bash
110+ ``` bash
111111php artisan make:provider ShortcodesServiceProvider
112112```
113113
@@ -128,6 +128,7 @@ php artisan make:provider ShortcodesServiceProvider
128128```
129129
130130ShortcodesServiceProvider.php Class File
131+
131132``` php
132133<?php namespace App\Providers;
133134
@@ -163,6 +164,7 @@ class ShortcodesServiceProvider extends ServiceProvider
163164### Default class for BoldShortcode
164165
165166You can store each shortcode within their class ` app/Shortcodes/BoldShortcode.php `
167+
166168``` php
167169namespace App\Shortcodes;
168170
@@ -172,13 +174,14 @@ class BoldShortcode {
172174 {
173175 return sprintf('<strong class =" %s" >%s</strong >', $shortcode->class, $content);
174176 }
175-
177+
176178}
177179```
178180
179181### Class with custom method
180182
181183You can store each shortcode within their class ` app/Shortcodes/ItalicShortcode.php `
184+
182185``` php
183186namespace App\Shortcodes;
184187
@@ -188,7 +191,7 @@ class ItalicShortcode {
188191 {
189192 return sprintf('<i class =" %s" >%s</i >', $shortcode->class, $content);
190193 }
191-
194+
192195}
193196```
194197
@@ -203,10 +206,43 @@ class BoldShortcode {
203206 {
204207 return '<strong ' . $shortcode->get(' class ' , ' default ' ) .' >' . $content . '</strong >';
205208 }
206-
209+
207210}
208211```
209212
213+ ## Shortcode Artisan Generator Command
214+
215+ This package provides an Artisan command to quickly generate shortcode classes:
216+
217+ ``` php
218+ php artisan make:shortcode YourShortcodeName
219+ ```
220+
221+ - By default, this creates a new class in ` app/Shortcodes/YourShortcodeNameShortcode.php ` .
222+ - If the file already exists, use the ` --force ` option to overwrite:
223+
224+ ``` bash
225+ php artisan make:shortcode YourShortcodeName --force
226+ ```
227+
228+ ### Customizing the Stub
229+
230+ You can publish the stub file to customize the generated class:
231+
232+ ``` bash
233+ php artisan vendor:publish --tag=shortcode-stubs
234+ ```
235+
236+ This will copy the stub to ` resources/stubs/shortcode.stub ` in your Laravel app. Edit this file to change the template for new shortcode classes.
237+
238+ ## Testing
239+
240+ To run the tests for the shortcode generator command:
241+
242+ ``` bash
243+ composer test
244+ ```
245+
210246## Change log
211247
212248Please see [ CHANGELOG] ( CHANGELOG.md ) for more information what has changed recently.
@@ -221,8 +257,8 @@ If you discover any security related issues, please email
[email protected] inst
221257
222258## Credits
223259
224- - [ Asif Iqbal] [ link-author ]
225- - [ All Contributors] [ link-contributors ]
260+ - [ Asif Iqbal] [ link-author ]
261+ - [ All Contributors] [ link-contributors ]
226262
227263## Support me
228264
@@ -238,7 +274,6 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
238274[ ico-scrutinizer ] : https://img.shields.io/scrutinizer/coverage/g/webwizo/laravel-shortcodes.svg?style=flat-square
239275[ ico-code-quality ] : https://img.shields.io/scrutinizer/g/webwizo/laravel-shortcodes.svg?style=flat-square
240276[ ico-downloads ] : https://img.shields.io/packagist/dt/webwizo/laravel-shortcodes.svg?style=flat-square
241-
242277[ link-packagist ] : https://packagist.org/packages/webwizo/laravel-shortcodes
243278[ link-travis ] : https://travis-ci.org/webwizo/laravel-shortcodes
244279[ link-scrutinizer ] : https://scrutinizer-ci.com/g/webwizo/laravel-shortcodes/code-structure
0 commit comments