jadu / pulsar-symfony
将Jadu的Pulsar集成到Symfony中作为一个包
dev-master
2020-05-18 15:48 UTC
Requires
- jadu/pulsar: dev-symfony-forms as 10.3.1
- symfony/form: ^3.4
- symfony/framework-bundle: ^3.4
- symfony/twig-bundle: ^3.4
Requires (Dev)
- jadu/php-style: ^1.3
- phpunit/phpunit: ^7.5
- symfony/translation: ^3.4
- symfony/twig-bridge: ^3.4
- symfony/validator: ^3.4
- dev-master
- dev-dependabot/npm_and_yarn/qs-and-grunt-contrib-connect-6.5.3
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/minimatch-and-browserify-and-grunt-and-grunt-contrib-compress-3.0.4
- dev-dependabot/npm_and_yarn/jquery-ui-1.13.2
- dev-dependabot/npm_and_yarn/moment-2.29.4
- dev-dependabot/npm_and_yarn/grunt-1.5.3
- dev-dependabot/npm_and_yarn/minimist-1.2.6
- dev-dependabot/npm_and_yarn/ajv-6.12.6
- dev-dependabot/npm_and_yarn/cached-path-relative-1.1.0
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/glob-parent-5.1.2
- dev-dependabot/npm_and_yarn/hosted-git-info-2.8.9
- dev-dependabot/npm_and_yarn/handlebars-4.7.7
- dev-dependabot/npm_and_yarn/y18n-3.2.2
- dev-dependabot/npm_and_yarn/elliptic-6.5.4
- dev-dependabot/npm_and_yarn/ini-1.3.8
This package is not auto-updated.
Last update: 2024-09-13 04:54:29 UTC
README
此包提供了将Pulsar集成到Symfony中的功能。
安装
确保全局已安装Composer,具体请参阅Composer文档中的安装章节。
步骤1:下载包
打开命令行,进入项目目录,并执行以下命令以下载此包的最新稳定版本
$ composer require jadu/pulsar-symfony
步骤2:启用包
然后,将包添加到项目中的注册包列表中,修改app/AppKernel.php
文件
// app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = [ // ... new \Jadu\Bundle\PulsarBundle\JaduPulsarBundle(), ]; // ... } // ... }
用法
Twig 辅助函数
Pulsar的Twig辅助函数自动注册在@JaduPulsar
命名空间下。
有关如何使用twig辅助函数的信息,请参阅Pulsar文档。
示例
{% import '@JaduPulsar/v2/helpers/html.html.twig' as html %} {{ html.panel({ 'title': 'In West Philadelphia born and raised', 'body': 'In the playground was where I spent most of my days.', 'icon': 'info-sign' }) }}
Twig 扩展
Pulsar的Twig扩展自动注册到twig。
其中一些辅助函数是使用twig辅助函数或Symfony表单主题所必需的。
示例
Created {{ product.createdAt|time_ago }}
Symfony 表单主题
此包提供了必要的twig,以便将Symfony内置表单类型主题化为Pulsar。
建议将主题设置为默认
# app/config/config.yml twig: form_themes: - '@JaduPulsar/forms.html.twig'
注册后,使用Symfony内置表单类型生成的表单将被Pulsar样式化。
额外的Symfony 表单类型
此包为Pulsar提供的表单组件提供了额外的表单类型,这些类型不是Symfony内置的。
这些可以在Jadu\Bundle\PulsarBundle\Form
命名空间中找到。
示例
use Jadu\Bundle\PulsarBundle\Form\ToggleSwitchType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; class MyType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add( 'enabled', ToggleSwitchType::class, [ 'required' => false, ] ); // ... } // ... }