This issue is about implementing a drupal://[module|theme|...]/[name]/[file] streamwrapper that is able to load code from PHAR archives.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Damien Tournoud’s picture

Development branch: 8.x-1185360 in my sandbox.

Damien Tournoud’s picture

Status: Active » Needs review
FileSize
9.62 KB

With this, I can install Drupal and load a module from a .phar archive in any modules directory.

Damien Tournoud’s picture

FileSize
6.83 KB

Example of PHAR archive (strip the .gz suffix).

Status: Needs review » Needs work

The last submitted patch, 1185360.patch, failed testing.

chx’s picture

Nice. Love it. Note that the stream wrapper does not support directories AFAIK and so you can just drop those. In fact, if all the stream_wrapper is doing is include 'drupal://' then stream_open, stream_read and stream_eof is enough.

Damien Tournoud’s picture

Status: Needs work » Needs review
FileSize
18.4 KB

That should fix the tests, hopefully. Also, completely removed drupal_get_filename() now.

chx’s picture

Oh you are using the phar archives as directories! Very clever. I hope the bot passes. Will review more.

Status: Needs review » Needs work

The last submitted patch, 1185360.patch, failed testing.

Damien Tournoud’s picture

Status: Needs work » Needs review
FileSize
17.84 KB

Removed an unnecessary change in file.inc that prevent http-based file URLs from being rendered properly.

neclimdul’s picture

sub

cweagans’s picture

Maybe I'm missing something: why should this be in core?

catch’s picture

Subscribing.

sun’s picture

Issue tags: +Framework Initiative
+++ b/includes/bootstrap.inc
@@ -538,102 +540,6 @@ function drupal_settings_initialize() {
-function drupal_get_filename($type, $name, $filename = NULL) {

+++ b/modules/simpletest/tests/bootstrap.test
@@ -321,37 +321,38 @@ class HookBootExitTestCase extends DrupalWebTestCase {
-    $this->assertIdentical(drupal_get_filename('module', 'php'), 'modules/php/php.module', t('Retrieve module location.'));
+    $this->assertIdentical(DrupalModuleStreamWrapper::getBaseFileName('module', 'php'), 'modules/php/php.module', t('Retrieve module location.'));

Wondering whether it would make sense to keep drupal_get_filename() as simple procedural wrapper?

24 days to next Drupal core point release.

droplet’s picture

love to see this on drupal +1. Subscribing

Crell’s picture

Subscribing.

While I don't know that modules should ship as phar archives, once we have a lot more namespaced class-per-file code it may be better to use a built phar archive rather than a built mega-file to reduce autoloading. See related discussion here: #1241190: Possible approaches to bootstrap/front loading of classes

RobLoach’s picture

Status: Needs review » Needs work
+++ b/includes/bootstrap.incundefined
@@ -158,6 +158,8 @@ define('REGISTRY_WRITE_LOOKUP_CACHE', 2);
 define('DRUPAL_PHP_FUNCTION_PATTERN', '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*');
 
+require_once DRUPAL_ROOT . '/includes/module-fs.inc';
+

We could save ourselves this line of code if we just place the file at core/lib/Drupal/Core/StreamWrapper/ModuleStreamWrapper.php and stick use Drupal\Core\StreamWrapper\ModuleStreamWrapper; at the top of each file we use it in.

-10 days to next Drupal core point release.

sinasalek’s picture

Brilliant idea

shariharan’s picture

Can D7 work from PHAR archive?

jerry_pham’s picture

Issue summary: View changes

Does this refactor make it possible to run Drupal completely from a PHAR archive?

deviantintegral’s picture

Status: Needs work » Closed (won't fix)

I did a pretty deep dive into PHAR archives a few months back, investigating to see if they were suitable for a D8 deployment. I found several issues including:

Given the lack of updates on this patch, and all the above, I'm closing as wontfix. PHARs are great for CLI tools, but not for for web facing apps.