SymfonyExtension
SymfonyExtension copied to clipboard
Kernel autodiscover
I think that
https://github.com/FriendsOfBehat/SymfonyExtension/blob/2f038b27c60cf56b24f41a451d7e211975008c2f/src/ServiceContainer/SymfonyExtension.php#L210
should be, somehow, parametric as with this check we're forced to run behat command from the same folder of app
.
WDYT?
Makes sense, using %paths.base%
could help here.
Sorry to be late on this.
Are you sure that %pahts.base%
would be the right choice?
I mean, %paths.base%
can easly contain any path so it would be virtually impossible to create a "fixed" path to discover the Kernel.php
file.
Am I missing something?
%paths.base%
is the directory that contains Behat config file IIRC.
Yes, indeed but it could be placed wherever so that's no way to reach the Kernel.php
in univocal fashion I suppose. Am I missing something?
We need to rely on either the current working directory or the directory with Behat config files in order to autodiscover the kernel file. The purpose of the autodiscovering itself is to guess the path, while still leaving the possibility for someone to define their own path.
I know this but using %paths.base%
is literally not valid like "guessing" that we're running the command from the root of the project (so where app/
dir could be found).
I don't know if there's any symfony parameter that would help us to find the directory of Kernel.php
, have to take a look.
If it is not, I would close this as using %paths.base%
seems not to enhance the current mechanism from my standpoint.
@DonCallisto yeah, I don't think there's any other way except for looking for the kernel location in common files like public/index.php
or bin/console
, which are the only points in standard Symfony applications that explicitly refer to the currently used kernel.
Could you provide which scenario is currently not working for you that could be solved here? (I mean in which way you would run behat
that makes the current implementation not working as expected)
I think that bin/console
would be ok.
The scenario is where you run Behat outside the root of the project without specifiying my own path with the configuration. I know that sounds like that's not a problem, and indeed it isn't, I was just arguing about the fact that app/Kernel.php
sounds no good as it is a relative path.
In my case the solution would be to explicitly specify the path of Kernel.php
that is in the "standard" path so it seems a little bit "strange".
Is there any news on this feature? :)
@wapcrazut I've tried an implementation but I failed (and TBH, I didn't spent too much time on this). As you can specify Kernel path in configuration, for the moment, I've switched to that solution. BTW this would be a nice feature. Any implementation idea?
I tried to give it a shot, but it looks like it wouldn't work with Behat's autoloading:
if (is_file($autoload = getcwd() . '/vendor/autoload.php')) {
require $autoload;
}
That's the snippet from vendor/bin/behat
that makes it dependent on the current working directory.
Umh, I guess we cannot do anything better...