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

Allow namespaced and autoloaded custom actions #94

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

oscherler
Copy link

With this PR, when specifying prerequisites and actions, names containing a backslash are treated as full class names, and thus are not prefixed by the internal namespaces, nor suffixed by type. This allows to use:

  • classes from the current project if RMT is installed as a Composer dependency;
  • globally installed classes if RMT is installed globally with Composer.

Moreover, inspired by PHPUnit’s bootstrap parameter, a bootstrap script can be specified in the configuration. This allows, for example, to use classes from the current project if RMT is installed globally and the project has an autoloader. Typically:

_default:
    bootstrap: vendor/autoload.php
    # ...

Tests are included for the configuration merging and class resolution features of Config\Handler.

The use cases for me are:

  • being able to write generic custom prerequisites and actions and installing them globally to use in many projects;
  • being able to write project-specific prerequisites and actions in projects that use Composer and having them follow the same namespace and autoloading conventions as the project.

I think this PR does the trick, but I may have missed something. I’ll be glad to receive feedback about it.

@jeanmonod
Copy link
Member

Hi @oscherler,

Thanks you for your contribution and sorry for the delay in my answer but I was offline all January. I think that your PR make a lot of sense. But as it's quite important, I would like to complete it two extra parts:

  • Some documentation lines in the README
  • A functional test of the bootstrapping feature (something like ExternalTasksTest.php)

Can you handle those two points or do you need help?

@oscherler
Copy link
Author

Sounds feasible, I’ll give it a try.

However, I just noticed a conflict if two different versions of the Console component are present, one in the RMT phar or installed globally with Composer and the other one loaded by the bootstrap script. I’ll have to see if I can solve this.

@jeanmonod
Copy link
Member

Hi @oscherler,
Any news on this one? Just tell me if you need support for the tests...

@oscherler
Copy link
Author

It’s not the tests that are blocking me, but the bootstrap functionality. If I have RMT installed globally with Composer, and I add a bootstrap file that loads my project’s Composer autoload.php, and if my project has, for example, a version of the Console component different than the one I have installed globally, then some classes will be loaded in the wrong version and it will break RMT.

Maybe I should remove the bootstrap functionality while I figure out a better way? It would at least support globally loaded classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants