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

Why does the installer copy c3.php into the project root? #40

Open
NerdyProjects opened this issue Nov 15, 2017 · 5 comments
Open

Why does the installer copy c3.php into the project root? #40

NerdyProjects opened this issue Nov 15, 2017 · 5 comments

Comments

@NerdyProjects
Copy link

I see no reason why it should not be included via composer autoloader or manually from within the vendor folder.

Is there any?

@DavertMik
Copy link
Member

DavertMik commented Nov 15, 2017

Can we detect the Composer's folder from a PHP script? Especially if we inject c3 in the very first lines of index.php.
Not sure, maybe it's technically possible, but there were reasons to drop file into the root...

@NerdyProjects
Copy link
Author

Is it not "common" and expected to have composer folder inside vendor? So I suggest

include __DIR__ . '/vendor/codeception/c3/c3.php';

To me, the copying approach fails as my test setup expects composer to not put anything outside the vendor/ folder. Also, it is not so nice having to add this to .gitignore.

I just feel that maybe changing the include path of c3.php when the vendor folder is relocated confirms much more to convenience & the general style of composer packages than this Installer approach.

Another possibility would be to use the composer autoloader by putting an empty class inside c3.php, so the file is executed when the class is referenced.

Can you point me to a discussion about the reasons to drop the file into the root? Maybe there are some usecases connected to frameworks etc. that I don't take into account now.

@DavertMik
Copy link
Member

Is it not "common" and expected to have composer folder inside vendor

No, it's not. Users can have a different location of composer's folder.
Also it can work with codecept.phar which was a default setup 3-4 years ago.

Another possibility would be to use the composer autoloader by putting an empty class inside c3.php, so the file is executed when the class is referenced.

This can be an option...

Can you point me to a discussion about the reasons to drop the file into the root? Maybe there are some usecases connected to frameworks etc. that I don't take into account now.

That was so long ago (I think January 2013)...
But here is the thing. c3 needs to know how to load codeception.yml:

https://github.com/Codeception/c3/blob/2.0/c3.php#L81

Looks like that's all...

So yeah, I think it can be refactored to load the config file by specifying it explicitly

@jkufner
Copy link

jkufner commented Sep 26, 2018

The c3.php setup is really messed up. It woud be much better like this:

<?php
// index.php
require dirname(__DIR__) . '/vendor/autoload.php';
Codeception\C3::init([
    'configFile' => dirname(__DIR__) . '/codeception.yml',
    'outputDir' => dirname(__DIR__) . '/temp/c3/'
]);

The init() argument is c3.php configuration -- the path to the config file, and the temp directory where c3 should place its outputs.

This way there is no need to put c3.php into application root directory. Composer's autoloader will do the trick. Moreover, it will work when only the dedicated directory is writable by the web server.

@marcovtwout
Copy link

See #72 for a first step in improving this.

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

No branches or pull requests

4 participants