cf symfony/symfony#21353 : Instead of using Symfony's autoloader in the Autoloaders, we should consider using Composer's. See the mentionned PR on symfony for more details.
I'd rather deprecate the behat autoloading config entirely, in favor of the autoload-dev feature of composer (which did not exist at the time it was added in Behat)
That's a good choice for Symfony projects, and similar 'modern' frameworks but not all projects use composer - consider a user running Wordpress and using behat.phar
I do agree we should encourage Composer usage, and we could do so in the current version of Behat by updating the documentation to include composer by default, but we need to consider how it will work in the use case of Behat as a stand-alone tool.
@ciaranmcnulty I think the key message here is that Symfony autoloader we use for this feature really goes away. Which means that if we are to support this feature in the future, we should either copy the component into our codebase or reimplement it.
So our choice is:
Dropping the feature does make it tricky to use behat.phar. But I'd rather bundle Composer into PHAR stub than drag dead component over.
We have the Composer ClassLoader class inside the phar, as Behat itself uses composer.
Yup. I meant exactly reappropriating that thing to autoloading features/bootstrap
Btw, using it should be a no-brainer, as the API of Symfony\Component\ClassLoader\ClassLoader is similar to the one of Composer\Autoload\ClassLoader
I do think autoloading feature should be turned off by default in non-phar version of 4.x. If you install Behat through Composer, you should use Composer for autoloading.
and probably even in phar versions when we can load the project-level composer autoloading file (we should warn users about using the composer autoload-dev for such cases even in 3.x)
What's the status of this since 3.3 is almost due date 馃摝 ?
I just ran an upgrade and am now running into the deprecation error every time I run tests. Is there any update/timeline on this?
This indeed looks "kind of" trivial to change (actually there are 2 or 3 calls that needs adapting, starting from the autoloader extension), but what I am clueless about is the Phar or how to handle the composer loader.... which is the main thing to handle actually.
If anyone could have any idea on how to handle this, the rest should be kinda straightforward.
@Taluu instantiate a new Composer ClassLoader when autoloading is configured in Behat (we should not try to alter the configuration of the instance generated by Composer, as it would kill the performance optimizations done in the generated autoloader).
And we should display a warning if it is configured without using the phar
Hi, I have the same issue than @MisterGlass. I'm not able to run Behat tests anymore, I always get this error:
SCREAM: Error suppression ignored for
Deprecated: The Symfony\Component\ClassLoader\ClassLoader class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead. in /var/www/app/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassLoader.php on line 14
Is there a way to remove this old autoloader extension? Because Composer handles classes autoloading.
I wrote something in relation to this issue: https://github.com/funk-spec/funk-spec/compare/fix/autoload
It is however modifying the generated classloader, which seems bad according to what @stof said above).
This is driving me nuts for the last 4 hours.
I have a problem after all tests run fine, the QuestionHelper of Symfony throws an "Undefined index: <nameOfMyContext>".
Someone have any idea?
@docteurklein I got in the same trouble yesterday and made another (simpler) solution. I think it's worth using until Behat gets rid of the Symfony's ClassLoader completely.
Most helpful comment
I just ran an upgrade and am now running into the deprecation error every time I run tests. Is there any update/timeline on this?