plan2net / fake-fal
TYPO3 Local FAL storage driver for fake files
Installs: 6 546
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 7
Forks: 4
Open Issues: 1
Type:typo3-cms-extension
Requires
- php: >=7.4
- ext-gd: *
- ext-pdo: *
- typo3/cms-core: ^10.4||^11
Conflicts
README
Create missing files on the fly for testing/development.
What does it do?
Instead of keeping gigabytes of files in sync with your test/development system, the extension creates useful fake files. It acts like a local file driver and creates missing files with the correct file signature (and in case of images in the original file's dimensions) and folders, so PHP's finfo (and others) return the correct mime type.
You can let the extension create fake files on the fly (when visiting a page in the browser) or create fake files for all files which are not available on disk at once via a command (Backend > Scheduler or command line).
Installation
Require the composer package:
composer require "plan2net/fake-fal" --dev
Activate the extension in the Extension Manager and update the settings.
You have to explicitely set the flag enable
to register the fake local driver.
enable = 1 (default is 0 = inactive)
Set an image generator
imageGeneratorType = Plan2net\FakeFal\Resource\Generator\LocalFakeImageGenerator
(Currently there's only one local image generator available, so just stick with the default value)
Save the configuration.
After activating the local fake driver globally, you have to activate the fake mode for specific local storages. Either via backend (by editing the storage record) or via command line command:
fake-fal:toggle
will set all local storages to fake mode.
fake-fal:toggle 2,14,99
will set the given storages (with ID 2
, 14
and 99
) to fake mode.
Available Commands:
fake-fal:list
List all existing storages as a table (command line only)
typo3 fake-fal:list
+----+---------------------------+--------+-----------+
| ID | Name | Driver | Fake mode |
+----+---------------------------+--------+-----------+
| 1 | fileadmin/ (auto-created) | Local | enabled |
| 2 | fileadmin_sec/ | Local | disabled |
+----+---------------------------+--------+-----------+
fake-fal:toggle
Set given storage(s) to fake mode: check flag for fake mode, clear processed files
fake-fal:create
Create fake files within given storage(s); the existing real files will be kept
Compatibility
The recent extension version works with TYPO3 CMS 10/11 and PHP >= 7.4. Use the versions < 3.0 for TYPO3 8 and 9 and PHP >= 7.0.
Integration information
We extend the core class \TYPO3\CMS\Core\Resource\ResourceFactory
to overcome the hardcoded check with is_file
in the method retrieveFileOrFolderObject
and we extend the core class \TYPO3\CMS\Core\Resource\ResourceStorage
to reset the isOnline
flag of the storage. Just be aware of this if you use any other extension doing so or extend the class yourself.
Alternatives
There's the filefill extension from Nicole Cordes.
Here's the story: I had the idea for plan2net/fake-fal for quite a while and there was a Fedex Day (a day where we explore new ideas and create cool things in our company) I wanted to create this extension. The result after one day of coding was the first working version.
This was around two weeks after Nicole published her extension. I didn't know anything about it. A week later a colleague said
Hey, I heard about an extension that sounds like yours!
At first I was dissappointed, but gladly there's quite a difference.
plan2net/fake-fal works offline and creates the files locally. Additionally the file dimensions are written into the fake images. And if you download a fake PDF it will behave like a real document.