evansmwendwa/filepicker-bundle

Symfony Bundle,用于向表单输入添加文件选择组件

安装: 21

依赖: 0

建议: 0

安全: 0

星星: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2018-01-13 14:57 UTC

This package is not auto-updated.

Last update: 2024-09-21 15:11:57 UTC


README

Symfony Bundle,用于向表单输入添加文件选择组件

警告:此包处于非常早期的开发阶段。使用风险自负

安装

步骤 1:下载 Bundle

打开命令行,进入您的项目目录,并执行以下命令以下载此 Bundle 的最新稳定版本

$ composer require evansmwendwa/filepicker-bundle "dev-master"

此命令需要您已全局安装 Composer,如 Composer 文档中的安装章节所述。

步骤 2:启用 Bundle

然后,通过将其添加到项目中的 app/AppKernel.php 文件中注册的 Bundle 列表中启用此 Bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Evans\FilepickerBundle\EvansFilepickerBundle(),
        );

        // ...
    }

    // ...
}

步骤 3:创建配置参数

# app/config/config.yml
evans_filepicker:
    uploads_destination: '/uploads/images'
    allow_uploads: true
    allowed_mimes: ['image/jpeg','image/png','image/gif']
    group_files: false

步骤 4:在 twig 中注册表单主题

# Twig Configuration
twig:
    form_themes:
        - EvansFilepickerBundle::form/fields.html.twig

步骤 5:在您的 Twig 模板中加载 Bundle 资产

此 Bundle 提供了两个 twig 函数用于加载必要的 HTML、CSS 和 JS。请将这些函数添加到您的 twig 模板中的某个位置。如果需要,也可以添加到基础模板中。

# loads necessary html and js files
{{ file_picker_init() }}
# loads necessary css files
{{ file_picker_init_css() }}

步骤 6:注册 FilepickerBundle 路由

# app/config/routing.yml

evans_filepicker:
    resource: "@EvansFilepickerBundle/Resources/config/routing.yml"
    prefix:   /

使用内置的 CKE 编辑器插件

说明即将推出

使用 File picker bundle 与 Symfony EasyAdminBundle

说明即将推出