Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Vendor Stream Wrapper

Security covered Under active development 1,628 sites

This module provides a vendor:// stream wrapper to allow Drupal to reference files located in the Composer vendor directory, even when that directory is outside the webroot. It enables the use of vendor files in *.libraries.yml files and provides a function to generate public URLs for these files. You can configure the vendor directory location and specify which files/directories within it should be publicly accessible.

Module Overview

Drupal and Composer working together is great for management of external libraries, that can be integrated into Drupal sites. It is a good practice to have the /vendor directory outside the webroot. The problem with moving the vendor out of the webroot however comes when trying to provide public URLs to files in the /vendor directory, such as CSS or JS files that are part of an external library.

This module provides a new stream wrapper, vendor://, that allows for referencing of files in the vendor directory. It works much the same as the private:// file wrapper provided by Drupal core. Along with this stream wrapper, this module sets up *.libraries.yml files to be parsed for vendor:// references, as can be seen in the code below.

example.libraries.yml:

some_library:
  js:
    vendor://vendor-name/package-name/js/some_file.js: {}
  css:
    theme:
      vendor://vendor-name/package-name/css/some_file.css: {}

The module also provides a helper function, vendor_stream_wrapper_create_url() for resolving vendor files to public facing URLs:

$public_url = vendor_stream_wrapper_create_url('vendor://vendor/package/file.css');

Configuration

This module will look first for the vendor first at ./vendor then at ../vendor. If no vendor folder is found, the system will crash. To fix this, set the location of the vendor folder path in settings.php as follows:

$settings['vendor_file_path'] = 'path/to/vendor/folder';

To prevent unwanted behavior (i.e., exposing files without a site owner's knowledge or intention), file/directory patterns should be explicitly provided by navigating to '/admin/config/media/vendor-stream-wrapper'. Indicate the patterns of files/directories located in the vendor directory that should be publically accessible.

Note: by default, no files can be downloaded using example.com/vendor_files/filename.ext, but the ://vendor stream wrapper (within the code) still works as expected.

Drupal 9–11

Ask your assistant about Vendor Stream Wrapper

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

2 tracked projects depend on this one

Activity

Tracked releases
5
Tracked since
Jun 2024
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
2.1.0 Stable 9–11 Oct 9, 2026
3.x-dev Dev 10–11 Jun 9, 2024
2.0.5 Stable 9–11 Jun 9, 2024
2.0.4 Stable 9–11 Jun 6, 2024
2.0.3 Stable 9–11 Jun 5, 2024