b13/distributed-flysystem
Composer 安装命令:
composer require b13/distributed-flysystem
包简介
Syncs files between frontend nodes in a multi-head environment based on PHP League / Flysystem
README 文档
README
Imagine you run a multi-head environment with TYPO3. Each application server is a "node".
As usual, there are caveats, and hurdles to work around with. Typically you have local cache files ("var/"), and (ideally) a FAL driver via a remote shared storage for "fileadmin". The database is on a cluster, and you run a Redis sentinel for shared caches.
But what about the other files that TYPO3 sometimes generates?
In an ideal world, TYPO3 would be handling most of the logic already, but due to some extensions or "compressed" files, some files get generated on e.g. "node 20" in typo3temp/ which aren't available on the other nodes.
In the past, we had NFS to work around this usually, but when NFS is not an option, we built a "workaround" extension for this, based on Frank De Jonge's Flysystem abstraction layer.
Every time a file in e.g. typo3temp gets accessed, and the file is not available
on this node, the other nodes are checked via SFTP and if one node has the
file, it is downloaded on the current nodes' typo3temp/ folder.
Currently, this extension is a "pull" solution - fetching the files if needed - but a deeper integration with the Local driver of the File Abstraction Layer should monitor this behavior as well in a separate step.
Installation
Set it up via composer: composer req b13/distributed-flysystem.
Configuration
Add a proper configuration for your SFTP connection to all your nodes in your LocalConfiguration for example:
$GLOBALS['TYPO3_CONF_VARS']['FILE']['flysystem'] = [
'default' => [
'rootPath' => '/path/from/sftp/ch-root/to/public/path/',
'username' => 'b13',
'password' => null,
'port' => 2222,
'privateKey' => Environment::getVarPath() . '/my-sftp_privkey',
'passphrase' => 'take it or leave it',
'timeout' => 10
],
'nodes' => [
'node01' => [
'host' => '1.2.3.4'
'alias' => 'primary'
],
'node02' => [
'host' => '1.2.3.5',
'username' => 'b14',
],
],
];
Modify your .htaccess file on each node to activate the "pulling" mechanism:
# Rewrite non-existent fileadmin and typo3temp files to a custom eID script
RewriteCond %{REQUEST_URI} "^(/fileadmin|/typo3temp/assets/).*" [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ %{ENV:CWD}index.php?eID=flysystem [QSA,L]
Caveats
It is expected that the rootPath variable is set to the folder of the public
directory of TYPO3's installation.
License
As TYPO3 Core, distributed flysystem is licensed under GPL2 or later. See the LICENSE file for more details.
b13/distributed-flysystem 适用场景与选型建议
b13/distributed-flysystem 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.24k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2021 年 01 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 b13/distributed-flysystem 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 b13/distributed-flysystem 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8.24k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2021-01-01