CKEditor 安装
由于许可限制(GPL、LGPL 和 MPL),CKEditor 源代码未与 bundle 捆绑在一起,而 bundle 依赖于 MIT 许可,两者不兼容。要安装 CKEditor 源代码,您可以使用内置的 Symfony 命令。
Composer 脚本
管理 CKEditor 安装和更新的最简单方法是在您的 composer 例程中间集成它(在清除缓存之后但在安装 assets 之前)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
{
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"ckeditor:install --clear=drop": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
}
}
Symfony 命令
1
$ php bin/console ckeditor:install
默认情况下,该命令将最新的 CKEditor 完整发行版(排除 samples 目录)下载到 bundle 的 Resource/public
目录中。大多数情况下,这正是您想要的,但该命令允许您执行更多操作。
下载路径
如果您不想将 CKEditor 下载到 bundle 的 Resource/public
目录中,您可以使用自定义路径(绝对路径)
1
$ php bin/console ckeditor:install /var/www/html/web/ckeditor
CKEditor 发行版
您可以选择要下载的 CKEditor 发行版(完整版、标准版或基本版)
1
$ php bin/console ckeditor:install --release=basic
CKEditor 自定义构建
也可以使用使用 CKEditor 在线构建器生成的自定义构建:https://ckeditor.npmjs.net.cn/cke4/builder。从 CKEditor 网站下载 ZIP 存档,并使用 `build-config.js` 文件中的自定义构建 ID
1
$ php bin/console ckeditor:install --release=custom --custom-build-id=574a82a0d3e9226d94b0e91d10eaa372
清除之前的安装
默认情况下,当检测到之前的 CKEditor 安装时,该命令将询问您如何处理,但在非交互模式下,您可以自动控制如何处理这种情况
1 2 3 4 5 6 7
$ php bin/console ckeditor:install --clear=drop
$ php bin/console ckeditor:install --clear=keep
$ php bin/console ckeditor:install --clear=skip
- ``drop``: Drop the previous installation & install.
- ``keep``: Keep the previous installation & install by overriding files.
- ``skip``: Keep the previous installation & skip install.
路径排除
提取下载的 CKEditor ZIP 存档时,您可以排除路径,例如 samples、adapters 等。
1
$ php bin/console ckeditor:install --exclude=samples --exclude=adapters
代理
如果您使用代理,可以使用以下环境变量
1 2
$ export HTTP_PROXY=http://127.0.0.1:8080
$ export HTTPS_PROXY=http://127.0.0.1:8080
您还可以定义请求 URI 是否应完整,使用
1 2
$ export HTTP_PROXY_REQUEST_FULLURI=true
$ export HTTPS_PROXY_REQUEST_FULLURI=true
本作品,包括代码示例,根据 Creative Commons BY-SA 3.0 许可获得许可。