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

Kernel autodiscover #89

Open
DonCallisto opened this issue Aug 28, 2019 · 12 comments
Open

Kernel autodiscover #89

DonCallisto opened this issue Aug 28, 2019 · 12 comments

Comments

@DonCallisto
Copy link
Contributor

I think that

if (file_exists('app/AppKernel.php')) {

should be, somehow, parametric as with this check we're forced to run behat command from the same folder of app.
WDYT?

@pamil pamil added the Bug label Sep 9, 2019
@pamil
Copy link
Member

pamil commented Sep 9, 2019

Makes sense, using %paths.base% could help here.

@DonCallisto
Copy link
Contributor Author

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?

@pamil
Copy link
Member

pamil commented Nov 26, 2019

%paths.base% is the directory that contains Behat config file IIRC.

@DonCallisto
Copy link
Contributor Author

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?

@pamil
Copy link
Member

pamil commented Nov 26, 2019

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.

@DonCallisto
Copy link
Contributor Author

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.

@pamil
Copy link
Member

pamil commented Nov 26, 2019

@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)

@DonCallisto
Copy link
Contributor Author

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".

@pamil pamil added RFC Feature and removed Bug labels Jan 13, 2020
@wapcrazut
Copy link

wapcrazut commented Feb 12, 2020

Is there any news on this feature? :)

@DonCallisto
Copy link
Contributor Author

@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?

@pamil
Copy link
Member

pamil commented Apr 4, 2020

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.

@pamil pamil added Help Wanted and removed RFC labels Apr 4, 2020
@DonCallisto
Copy link
Contributor Author

Umh, I guess we cannot do anything better...

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

No branches or pull requests

3 participants