function Composer::ensureHtaccess

Same name in other branches
  1. 9 core/lib/Drupal/Core/Composer/Composer.php \Drupal\Core\Composer\Composer::ensureHtaccess()

Ensures that .htaccess and web.config files are present in Composer root.

Parameters

\Composer\Script\Event $event:

File

core/lib/Drupal/Core/Composer/Composer.php, line 146

Class

Composer
Provides static functions for composer script events.

Namespace

Drupal\Core\Composer

Code

public static function ensureHtaccess(Event $event) {
    // The current working directory for composer scripts is where you run
    // composer from.
    $vendor_dir = $event->getComposer()
        ->getConfig()
        ->get('vendor-dir');
    // Prevent access to vendor directory on Apache servers.
    FileSecurity::writeHtaccess($vendor_dir);
    // Prevent access to vendor directory on IIS servers.
    FileSecurity::writeWebConfig($vendor_dir);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.