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):
- https://github.com/drustack/drustack-standard/blob/7.44.x/src/Composer/S...
- https://github.com/drustack/drustack-standard/blob/develop/src/Composer/...
Usage example:
Comment | File | Size | Author |
---|---|---|---|
#3 | drupal-8.2.x-composer_php_simplify_ensure_htaccess-2755739-3.patch | 1.58 KB | hswong3i |
Comments
Comment #2
hswong3i CreditAttribution: hswong3i commentedComment #3
hswong3i CreditAttribution: hswong3i commentedComment #4
hswong3i CreditAttribution: hswong3i commentedComment #5
hswong3i CreditAttribution: hswong3i commentedComment #12
Mile23vendorTestCodeCleanup() 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.