I've used numerous Symfony components in different add on modules for Aegir, in devshop and others.

It would be nice if we could add things like Process component, which would allow shell exec's with realtime feedback.

The upcoming branch adds a composer.json and vendor folder with the same version of symfony/class-loader we already have.

Now we can add packages to composer.json and use "use":


require_once dirname(__FILE__) . "/vendor/autoload.php";
use Symfony\Component\ClassLoader\UniversalClassLoader;

Note that currently, Provision is using the oldest available version of symfony/class-loader, so we might want to update that as well: https://packagist.org/packages/symfony/class-loader#2.0.4

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jon Pugh created an issue. See original summary.

Jon Pugh’s picture

Issue summary: View changes
Jon Pugh’s picture

Status: Active » Needs review
FileSize
27.23 KB

For your review.

  • Jon Pugh committed 98f218a on 2957156-composer-loader
    Issue #2957156: Convert Provision to include ClassLoader using composer....
Jon Pugh’s picture

Doesn't work yet, something with the autoloader.

  • Jon Pugh committed 6eb49a8 on 2957156-composer-loader
    Issue #2957156: Convert Provision to include ClassLoader using composer....
Jon Pugh’s picture

FileSize
44.69 KB

Yeah, my mistake! The composer-generated autoloader replaces class-loader.

I was able to get it working with just a minor change to provision code and the addition of composer.json, composer.update, and the vendor dir.

Jon Pugh’s picture

Some details: I was trying to see if I could remove the redundant hook_init() and hook_provision_register_autoload() functions that are required if you create your own Context Service or Config classes.

I added the two additional paths (db/Provision and http/Provision) to the psr-0 namespace config in composer.json, but when I removed db_provision_register_autoload(), db_drush_init(), and db_provision_register_autoload() it broke again.

I'm going to keep poking at it, I think we can just call provision_autoload_register_prefix() directly in hook_drush_init, and remove the extra hook_provision_register_autoload() functions. Since provision_autoload() already uses a static instance of the Classloader, I don't think we need some of these functions.

Jon Pugh’s picture

FYI it DID work when I moved all the db and http code to the same folder, so it was all in the same namespace.

  • helmo committed 818f072 on 2957156-composer-loader
    Issue #2957156: Update links
    
helmo’s picture

I updated a few strings in the composer.json file...

So we could safely merge the current state and refactor later? Or would it be better to dig a little deeper?

Jon Pugh’s picture

Yeah, if it works now I say go for it.

Any further development on this isn't really worth it since the branch will be deprecated at some point.

  • Jon Pugh committed 6eb49a8 on 7.x-3.x
    Issue #2957156: Convert Provision to include ClassLoader using composer....
  • helmo committed 7ed4fb8 on 7.x-3.x
    Issue #2957156: Update (only) links
    
  • helmo committed de1c753 on 7.x-3.x
    Issue #2957156: Merge branch '2957156-composer-loader' into 7.x-3.x
    
helmo’s picture

Status: Needs review » Fixed

Merged

helmo’s picture

Thanks Jon ... one step closer to provision4

  • helmo committed 5fb408f on 7.x-3.x
    Issue #2957156: adapt Debian packaging for a vendor dir
    
  • helmo committed 6a02973 on 7.x-3.x
    Issue #2957156: Up the php version in the composer file, phplint was...
Jon Pugh’s picture

This is fantastic, helmo!

We can now add Provision3 to Packagist, and require it in Provision4, which should let us figure out a way to load in all the 3.x drush commands.

Thanks for committing.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.