ichhabrecht/filefill
Composer 安装命令:
composer require ichhabrecht/filefill
包简介
Find and fetch missing local files from different remotes
README 文档
README
Find and fetch missing local files from different remotes.
Ever tried to set up a new system as copy from an existing one? Wondered if all the files (in fileadmin) are really needed? Ever run into the problem that a local file was missing?
Filefill fetches missing files from one or multiple remote servers to ensure you have all the files you need for the new system.
Once the configuration is set up, fetching can be triggered by loading a page with missing files in the frontend.
The extension requires the usage of FAL api to fetch missing files. Files are stored directly in the (local) storage folder (e.g. fileadmin). You can re-run filefill at any time by deleting the local files in the storage folder.
Installation
Simply install the extension with Composer as development dependency or the Extension Manager.
composer require --dev ichhabrecht/filefill
Usage
You need to configure resources for one or more existing file storages.
Prerequisite: Only storages with a "Local filesystem" driver are currently supported.
Resources for file storages can be configured using one of the two following options where the database record configuration is preferred if set. If not set, the TYPO3_CONF_VARS configuration is used.
Database record configuration
- go to the root of your TYPO3 page tree (id=0)
- change to the list module (Web -> List on the left side)
- find the "File Storage" section and edit a record
- change to the tab "File Fill" and select the enable checkbox
- define the resource chain that should be used to fetch missing files
TYPO3_CONF_VARS configuration
- given a file storage with uid 1, the configuration might look like this
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['filefill']['storages'][1] = [ [ 'identifier' => 'domain', 'configuration' => 'https://example.com', ], [ 'identifier' => 'domain', 'configuration' => 'https://another-example.com', ], [ 'identifier' => 'placehold', ], [ 'identifier' => 'imagebuilder', 'configuration' => [ 'backgroundColor' => '#FFFFFF', 'textColor' => '#000000', ], ], [ 'identifier' => 'static', 'configuration' => [ 'path/to/example/file.txt' => 'Hello world!', 'another' => [ 'path' => [ 'to' => [ 'anotherFile.txt' => 'Lorem ipsum', '*.youtube' => 'yiJjpKzCVE4', ], '*' => 'This file was found in /another/path folder.', ], ], '*.vimeo' => '143018597', '*' => 'This is some static text for all other files.', ], ], ];
- you don't need to configure resources that you don't want to use
- the ordering in your configuration defines the ordering of processing
Resources
Resources define the places (url / services) where filefill tries to fetch missing files from. You can use multiple resources to build some kind of fallback chain.
Single domain
Fetch missing files from a fixed url.
Configuration:
- Url: Enter a valid url (incl http/https scheme)
You can use multiple single domains within one resources configuration.
Placehold.co
Fetch a missing image from the placehold.co service. This fetches an image with the correct resolution of the original file.
Configuration:
- no configuration required (the checkbox is just a field placeholder)
There is no need for multiple usage. This resource can be the last one in the chain but can handle image files only.
Image builder
Create an empty image with the correct resolution of the original file. The height and width is added as a text layer.
Configuration:
- Background color: Enter a valid hex code as background color
- Text color: Enter a valid hex code as text color
Static file
Ensure missing files will be available. By default, an empty file will be created.
Configuration:
- You can configure the content of a file by its path or extension
Please use TypoScript syntax for record configuration.
path/to/example/file.txt = Hello world!
another {
path {
to {
anotherFile\.txt = Lorem ipsum
*\.youtube => yiJjpKzCVE4
}
* = This file was found in /another/path folder.
}
}
*\.vimeo = 143018597
* = This is some static text for all other files.
Additional resources
You can add own resource handlers to fetch files from additional services.
Registration
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['filefill']['resourceHandler']['identifierName'] = [
'title' => 'Name of the resource',
'handler' => \Vendor\Extension\Resource\ResourceHandler::class,
'config' => [
'label' => 'Name of the resource',
'config' => [
'type' => 'check',
'default' => 1,
],
],
];
- title: name of the resource that is taken as backend (flex) button label
- handler: name of the class that handels the actual implementation
- config: TCA configuration for the backend (flex) field
Handler
namespace Vendor\Extension\Resource;
class ResourceHandler implements \IchHabRecht\Filefill\Resource\RemoteResourceInterface
{
public function hasFile($fileIdentifier, $filePath, ?FileInterface $fileObject = null)
{
return true;
}
public function getFile($fileIdentifier, $filePath, ?FileInterface $fileObject = null)
{
return 'file content';
}
}
The handler needs to implement the interface \IchHabRecht\Filefill\Resource\RemoteResourceInterface and therefore has to
add both functions hasFile and getFile.
Debugging
You can enable additional log information by configuring a filefill logger.
$GLOBALS['TYPO3_CONF_VARS']['LOG']['IchHabRecht']['Filefill'] = [
'writerConfiguration' => [
\TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
\TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
'logFileInfix' => 'filefill',
],
],
],
];
Known issues
1509741907 TYPO3Fluid\Fluid\Core\ViewHelper\Exception
Folder "[...]" does not exist.
Filefill tries to fetch the existing file from any resource. However, due to the FAL api the exception cannot be prevented nor handled by filefill. Try to reload the page again, the exception (for this specific file) should not occur anymore. Please note that there might be a new exception for a new file. In this case you need to reload your page until all files were properly created on your current system.
Community
- Thanks to in2code that sponsored parts of the TYPO3 13 update
- Thanks to b13 that sponsored the maintenance of this extension with a sponsorship
- Thanks to Wolfgang Wagner who sponsored the maintenance of this extension with a sponsorship
- Thanks to Marcus Schwemer who wrote about filefill in his blog TYPO3worx
- Thanks to Thomas Löffler for his support as Patron
ichhabrecht/filefill 适用场景与选型建议
ichhabrecht/filefill 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.49M 次下载、GitHub Stars 达 69, 最近一次更新时间为 2018 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「file」 「extension」 「placeholder」 「missing」 「typo3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ichhabrecht/filefill 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ichhabrecht/filefill 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ichhabrecht/filefill 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
A plugin which generates an invisible SVG of specific dimensions for use when lazyloading images in Craft CMS templates.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
统计信息
- 总下载量: 1.49M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 71
- 点击次数: 17
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2018-03-02