【发布时间】:2016-02-17 11:50:18
【问题描述】:
从周日开始,我一直关注 symfony2 关于 CMF 媒体包 (here) 的文档,目的是下载图片并能够利用它们,我选择了不同的包:
#composer.json
"php": ">=5.5.9",
"symfony/symfony": "2.8.*",
#...
"components/jquery": "^2.2",
"stfalcon/tinymce-bundle": "^0.4.0",
"symfony-cmf/media-bundle": "^1.2",
"liip/imagine-bundle": "^1.4",
"helios-ag/fm-elfinder-bundle": "~4",
"jackalope/jackalope-doctrine-dbal": "1.2.*",
"doctrine/phpcr-odm": "1.2.*",
"doctrine/phpcr-bundle": "1.2.*"
(我从 symfony 3.0 开始这个项目,然后在没有任何正确安装的情况下降级到 2.8,但是由 composer update 提供的那个)。
这里是文档中给出的配置,几乎没有修改:
# app/config/config.yml
# Cmf Media
cmf_media:
persistence:
phpcr:
enabled: true
manager_name: ~
media_basepath: /cms/media
media_class: Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Media
file_class: Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\File
directory_class: Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Directory
image_class: Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Image
event_listeners:
stream_rewind: true
image_dimensions: true
imagine_cache: auto
# Liip imagine
liip_imagine:
filter_sets:
image_upload_thumbnail:
data_loader: cmf_media_doctrine_phpcr
filters:
thumbnail: { size: [100, 100], mode: outbound }
elfinder_thumbnail:
data_loader: cmf_media_doctrine_phpcr
quality: 85
filters:
thumbnail: { size: [48, 48], mode: inset }
# Elfinder
fm_elfinder:
instances:
default:
locale: %locale% # defaults to current request locale
editor: tinymce4 # ckeditor, other options are tinymce, tinymce4, fm_tinymce, form, simple, custom
tinymce_popup_path: "asset[bundles/stfalcontinymce/vendor/tinymce/tinymce.min.js]"
fullscreen: false # defaults true, applies to simple and ckeditor editors
include_assets: true # disable if you want to handle loading of the javascript and css assets yourself
connector:
debug: false # defaults to false
roots:
uploads:
show_hidden: false # defaults to false, hide files that
driver: LocalFileSystem
path: uploads
upload_allow: ['image/gif', 'image/png', 'image/jpg', 'image/jpeg', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation']
upload_deny: ['all']
upload_max_size: 2M
form:
locale: %locale% # defaults to current request locale
editor: form # other choices are tinymce or simple, and form
fullscreen: false # defaults true, applies to simple and ckeditor editors
include_assets: true # disable if you want to handle loading of the javascript and css assets yourself
connector:
debug: false # defaults to false
roots: # at least one root must be defined
uploads:
driver: LocalFileSystem
path: uploads
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
upload_deny: ['all']
upload_max_size: 2M
# doctrine phpcr
doctrine_phpcr:
odm:
auto_mapping: true
session:
backend:
type: doctrinedbal
logging: true
profiling: true
workspace: default
username: ******
password: ******
# tinymce
stfalcon_tinymce:
include_jquery: false
tinymce_jquery: true
selector: ".tinymce"
base_url: %base_url%
tinymce_buttons:
stfalcon: # Id of the first button
title: "Stfalcon"
image: "http://stfalcon.com/favicon.ico"
theme:
simple: ~
advanced:
entity_encoding: "raw"
file_browser_callback : elFinderBrowser
plugins:
- "advlist autolink lists link image charmap print preview hr anchor pagebreak"
- "searchreplace wordcount visualblocks visualchars code fullscreen"
- "insertdatetime media nonbreaking save table contextmenu directionality"
- "emoticons template paste textcolor"
file_browser_callback : elFinderBrowser
toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media | forecolor backcolor emoticons | example"
image_advtab: true
templates:
- {title: 'Test template 1', content: 'Test 1'}
- {title: 'Test template 2', content: 'Test 2'}
# BBCode tag compatible theme (see http://www.bbcode.org/reference.php)
bbcode:
plugins: ["bbcode, code, link, preview"]
menubar: false
toolbar1: "bold,italic,underline,undo,redo,link,unlink,removeformat,cleanup,code,preview"
这是 html.twig 文件中使用的 javascript:
{% javascripts
'@jquery'
'@file_browser' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{{ tinymce_init() }}
和设置:
assets:
jquery:
inputs:
- '%kernel.root_dir%/../vendor/components/jquery/jquery.min.js'
file_browser:
inputs:
- '%kernel.root_dir%/../web/bundles/fmelfinder/js/elfinder.min.js'
- '%kernel.root_dir%/../web/bundles/fmelfinder/js/tinymce.js'
- '%kernel.root_dir%/../web/bundles/stfalcontinymce/js/init.jquery.js'
当我期待这样的事情时(从http://localhost/app-dev.php/elfinder 获取,这是测试和使用 elfinder 包的默认 URL):
elfinder 和 tinymce 的参数配置失败在哪里? 我应该正确安装 2.8 版本的 symfony2 吗?
编辑 1: 这是路由文件:
...
cmf_media_file:
resource: "@CmfMediaBundle/Resources/config/routing/file.xml"
cmf_media_image:
resource: "@CmfMediaBundle/Resources/config/routing/image.xml"
_liip_imagine:
resource: "@LiipImagineBundle/Resources/config/routing.xml"
elfinder:
resource: "@FMElfinderBundle/Resources/config/routing.yml"
【问题讨论】:
-
经过一番研究,我使用命令行:
doctrine:phpcr:repository:init,这让我绕过了最后一个问题。但现在我有了这个:Unable to open "default folder". Folder not found. -
嗨。你找到解决这个问题的方法了吗?
标签: javascript symfony tinymce elfinder