Up-and-running with Stage File Proxy in less than 5 minutes

 

Video transcript

Hello and welcome to another DrupalEasy screencast, my name is Mike Anello and today we'll be taking a quick look at the Stage File Proxy module.

This module is super-useful in that it provides on-demand access to content files in your local development environment that are initial served from a different remote environment.

For example, the live environment of academy.drupaleasy.com has this page about our community mentors and it includes this content image.

In my local environment, I've only copied the database down from the production environment, not the files directory, so the same page on my local is missing the content image.

By using Stage File Proxy in my local environment, I can configure it to automatically fetch images from the live environment.

You can imagine how useful this can be - especially when the production files directory is multiple gigabytes in size.

Lucky for us, the Stage File Proxy module is really easy to use.

First, get the module using Composer.

Next, enable the module - it is really important that this module only be enabled on your local site.

The final step is to configure the module to instruct it where to look for the source of the content files. In this case, it will be the live academy.drupaleasy.com site.

Configuration for the module can be done a few different ways, but I prefer adding its configuration directly to my local site's settings.local.php file.

Rebuild caches and you're done. The next time you go to load a page on your local site that includes content files, as long as those content files exist on the remote site, Stage File Proxy will do the rest!

Thanks for watching this DrupalEasy video quicktip, and don't forget about our best-practice focused, long-form, live-instructor, online Drupal training courses!

Bonus information about Stage File Proxy and configuration management

Since Stage File Proxy is only meant to be used on local (personal) development sites, its configuration should not be exported and committed for use in remote development environments. There are several ways of preventing this from happening - I'll mention two of them briefly:

Option 1: assuming you're using settings.local.php (if not, why not?!), simply ensure that stage_file_proxy is included in the list of excluded modules in that file:

$settings['config_exclude_modules'] = ['devel', 'stage_file_proxy', 'upgrade_status'];

Option 2: utilize the Config Split module to split out the Stage File Proxy module configuration for your local (personal) environment. 

Add new comment