Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Change to use Composer for autoload, drop PEAR/EZC #1340

Merged
merged 4 commits into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
require_once __DIR__ . '/config.php';
}

// If composer autoloaded context such as eZ Platform & legacy bridge, skip trying to autoload Zeta Components and such
if ( class_exists( 'Composer\Autoload\ClassLoader', false ) )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had forgot about that one.

It's more or less the same, so not needed then. Only difference is that this also detects usage in plain legacy. As in:

require __DIR__ . '/vendor/autoload.php';

$ini = eZINI::instance();
echo $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' );

That said I'm unsure if allowing yet another way to do things is good. So I'll gladly remove it.

Copy link
Contributor Author

@andrerom andrerom Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But main reason I added it is because I need it in order to be able to do the section in composer:

    "autoload": {
      "files": ["autoload.php"]
    },

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I'll test the patch tomorrow to see how it behaves.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, is there a point in using Composer autoloading in context of pure legacy, seeing how you just can do require autoload.php, instead of require vendor/autoload.php and achieve the exact same thing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emodric I imagine this allows using composer-installed dependencies in a pure-legacy context... An interesting concept - albeit probably not many legacy extensions are currently available that take advantage of this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

albeit probably not many legacy extensions are currently available that take advantage of this

@gggeek If any, hence, my question :) But I suppose there's no harm done in allowing Composer autoloading too.

Copy link
Contributor Author

@andrerom andrerom Jan 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, is there a point in using Co

As said, this is not the main point* of this, just a side benefit/downside however you look at it. I know many legacy parts don't use compoer and never will, exhibit A: package system as used by setup wizard.

* Main point: To auto register legacy autoload in composer in a Platform + Legacy Bridge setup to get rid of dependency on app/autoload.php which was removed in Symfony 3 and hence also eZ Platform v2 as there is no need for it. Somewhat pure composer autoloading for the win 🎉

{
define( 'EZCBASE_ENABLED', false );
}

if ( !defined( 'EZCBASE_ENABLED' ) )
{
$defaultAppName = "app";
Expand Down
14 changes: 14 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@
"phpunit/phpunit": "3.7.*",
"zetacomponents/php-generator": "~1.1"
},
"autoload": {
"files": ["autoload.php"]
},
"scripts": {
"legacy-scripts": [
"@php bin/php/ezpgenerateautoloads.php"
],
"post-install-cmd": [
"@legacy-scripts"
],
"post-update-cmd": [
"@legacy-scripts"
]
},
"conflict": {
"ezsystems/ezpublish-kernel": "<6.12 || >=2014.11 <2017.10"
},
Expand Down