Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

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.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Jun 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
3.x-dev Dev Jun 9, 2024
2.0.5 Stable Jun 9, 2024
2.0.4 Stable Jun 6, 2024
2.0.3 Stable Jun 5, 2024