Our own stream wrapper
At the beginning of this chapter, we briefly talked about stream wrappers and what they are used for. We saw that Drupal comes with four stream wrappers that map to the various types of file storage it needs. Now it's time to see how we can create our own. And the main reason why we would want to implement one is to expose resources at a specific location, to PHP's native filesystem functions.
In this example, we will create a very simple stream wrapper that can basically only read the data from the resource. Just to keep things simple. And the data resource will be the product images hosted remotely (the ones we are importing via the JSON Importer). So there will be some rework there to use the new stream wrapper instead of the absolute URLs. Moreover, we will also learn how to use the site-wide settings service by which we can have environment-specific configurations set in the settings.php
file and then read by our code.
The native way of registering...