Drupal\Core\Composer\Composer::ensureHtaccess() is now using Drupal\Component\PhpStorage\FileStorage::htaccessLines() for generating .htaccess, during post-autoload-dump phase when running composer.

Ideally when implementing something similar as Composer Template for Drupal Project, we should include the line "post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess" inside template's composer.json, so the generation of .htaccess will handle automatically, and so refer to the latest changes inside Drupal core, too.

BTW, when developing my DruStack Standard Edition for both Drupal 7.x/8.x, I found that will NOT works for 7.x branch if just simply copy-and-paste the composer.json from 8.x branch, because we DON'T (yes for sure, ever and never) have the class Drupal\Component\PhpStorage\FileStorage inside Drupal 7.x source code!

Anyway, since 99.99% of code inside Drupal\Core\Composer\Composer::ensureHtaccess() are already portable for Drupal 7.x/8.x composer template development unless the call to Drupal\Component\PhpStorage\FileStorage::htaccessLines(), now I coming with a solution that:

  • Clone core/lib/Drupal/Core/Composer/Composer.php entirely as my own ScriptHandler.php
  • Modify the call to Drupal\Component\PhpStorage\FileStorage::htaccessLines() as hard code style (i.e. as patch attached)
  • Now I can synchronize the ScriptHandler.php bewteen both 7.x branch and 8.x branch with no additional modification

Long story short, this proof the call to Drupal\Component\PhpStorage\FileStorage::htaccessLines() is not a must, where transform it as hard code implementation can even give a good reference and starting point for composer template development for Drupal.

Original implementation cloned from (ok these 2 files are just identical):

Usage example:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hswong3i created an issue. See original summary.

hswong3i’s picture

hswong3i’s picture

hswong3i’s picture

hswong3i’s picture

Issue summary: View changes

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Status: Needs review » Closed (outdated)

vendorTestCodeCleanup() has been moved to a Composer plugin: https://www.drupal.org/node/3059717

The htaccess and web.profile file generators have been moved to their own Drupal component, which might be usable in a Drupal 7 project as needed: https://www.drupal.org/node/3075098

Closing here. Thanks, @hswong3i.