gornymedia/laravel-shortcodes
Composer 安装命令:
composer require gornymedia/laravel-shortcodes
包简介
Laravel shortcodes package
关键字:
README 文档
README
Laravel Shortcodes Package
Laravel compatibility
| Laravel | Shortcodes |
|---|---|
| 12.x | 1.5 |
| 11.x | 1.5 |
| 10.x | 1.4 |
| 9.x | 1.4 |
| 8.x | 1.4 |
| 7.x | 1.4 |
| 6.x | 1.4 |
| 5.8.x | 1.3 |
| 5.5.x | 1.2 |
| 5.4.x | 1.1 |
| 5.3.x | 1.1 |
| 5.2.x | 1.1 |
| 5.1.x | 1.0 |
| 5.0.x | 1.0 |
Installation
Require this package with Composer
composer require gornymedia/laravel-shortcodes 1.5
Add the service provider to bootstrap/providers.php
Gornymedia\Shortcodes\ShortcodesServiceProvider::class,
To use the facades, add this within the register method of app/Providers/AppServiceProvider
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Shortcode', \Gornymedia\Shortcodes\Facades\Shortcode::class);
Copy the package config to your local config with the publish command
php artisan vendor:publish --provider="Gornymedia\Shortcodes\ShortcodesServiceProvider"
Usage
Creating shortcodes
Inside an app/Providers/AppServiceProvider boot function you can create the shortcodes with attributes.
use Gornymedia\Shortcodes\Facades\Shortcode; Shortcode::add('example', function($atts, $content, $name) { $a = Shortcode::atts([ 'name' => $name, 'foo' => 'something', ], $atts); return "foo = {$a['foo']}"; }); Usage : [example foo="something else"]
Include partial files in shortcode
use Gornymedia\Shortcodes\Facades\Shortcode; Shortcode::add('widget', function($atts, $content, $name) { $a = Shortcode::atts([ 'name' => $name, 'foo' => 'something' ], $atts); $file = 'partials/' . $a['name'] ; // ex: resource/views/partials/ $atts['name'] .blade.php if (view()->exists($file)) { return view($file, $a); } }); Usage : [widget name="maps"]
Compile shortcodes inside shortcode content
use Gornymedia\Shortcodes\Facades\Shortcode; Shortcode::add('strong', function($atts, $content, $name) { $content = Shortcode::compile($content); return "<strong>$content</strong>"; }); Usage: [strong][example][/strong]
View rendering
compileShortcodes()
To render the view and compile the Shortcodes:
return view('view')->compileShortcodes();
stripShortcodes()
To render the view and remove the Shortcodes
return view('view')->stripShortcodes();
In the config/gornymedia-laravel-shortcodes.php file you can set the default mode (null, compile or strip).
The following example will compile shortcodes without using the compileShortcodes() method
return [ 'mode' => 'compile' ];
License
This package is open-source software licensed under MIT License.
This package uses WordPress shortcodes methods. The license under which the WordPress software is released is the GPLv2 (or later).
Support
Support me with any amount and help me develop.
gornymedia/laravel-shortcodes 适用场景与选型建议
gornymedia/laravel-shortcodes 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40.96k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2015 年 02 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「shortcodes」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gornymedia/laravel-shortcodes 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gornymedia/laravel-shortcodes 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gornymedia/laravel-shortcodes 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Anax TextFilter module, frontmatter, shortcodes, markdown.
Use Wordpress-style shortcodes in your Twig templates.
Use Wordpress-style shortcodes in your Twig templates.
A package to manage and generate string with tokens/shortcodes for Eloquent Models
Tinymce and Quicktag buttons (and modals) for outputting shortcodes. Built to work with CMB2.
Alfabank REST API integration
统计信息
- 总下载量: 40.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-22