flownative / flow-resourceproxy
A Flow package that transparently imports missing resources from a remote source
Installs: 2 027
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 3
Open Issues: 1
Type:neos-package
Requires
- php: ^7.4 || ^8.0 || ^8.1
- neos/flow: ^6.0 || ^7.0 || ^8.0
README
Flownative.Flow.ResourceProxy
Description
This Flow package allows to transparently import resource data from other systems into Flow. It does this by providing an implementation that tries to fetch missing resources from a remote source. When a resource can be fetched, it is "imported" and available as usual, otherwise the system behaves as usual when a resource is missing.
Because Neos CMS is using Flow's resource management under the hood, this also works nicely for assets in Neos.
This is mostly useful for local development, as it removes the need to copy all resources to the lcoal machine along with a database dump.
Installation
The Flownative Resource Proxy is installed as a regular Flow package via Composer.
For your existing project, simply include flownative/flow-resourceproxy
into
the dependencies of your Flow or Neos distribution:
composer require flownative/flow-resourceproxy
Configuration
To import, the package needs to know the base URI of the remote source and whether or not it uses subdivided hash path segments.
Flownative: Flow: ResourceProxy: storages: # the default storage for a Flow setup 'defaultPersistentResourcesStorage': # the remote base URI to the published resources remoteSourceBaseUri: 'https://www.acme.com/_Resources/Persistent' # whether or not the remote source uses the target setting of the same name subdivideHashPathSegment: true
After setting up the configuration, clear the Fusion cache to make sure the URIs will be fetched again and can be checked for needing an import. Similarly, clearing the existing thumbnails will force the system to re-generate them.
Troubleshooting
If things don't work as expected, check the system log, the package is pretty talkative in the debug log level.
Implementation
In Flow, resource access is handled through the resource management API. These mehods would need to check for a missing resource and try to fetch it if not available locally:
StorageInterface.getStreamByResource
StorageInterface.getStreamByResourcePath
(unused in a plain Neos setup)TargetInterface.getPublicPersistentResourceUri
The following are covered by the above methods:
Collection.getStreamByResource
viaStorageInterface.getStreamByResource
ResourceManager.getStreamByResource
viaCollection.getStreamByResource
ResourceManager.getPublicPersistentResourceUri
viaTargetInterface.getPublicPersistentResourceUri
ResourceManager.getPublicPersistentResourceUriByHash
viaTargetInterface.getPublicPersistentResourceUri
On top of that the system uses image variants and thumbnails, assuming those
exist if their metadata can be found in the database. Still, the URI for those
is fetched using the TargetInterface.getPublicPersistentResourceUri
method.
This package thus advises the StorageInterface
and TargetInterface
to
check for missing resources and tries to "import" them as needed.
Note: So far this only works for the WritableFileSystemStorage
.