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

When installed globally local autoloader is loaded #18

Open
szepeviktor opened this issue Mar 23, 2020 · 10 comments
Open

When installed globally local autoloader is loaded #18

szepeviktor opened this issue Mar 23, 2020 · 10 comments

Comments

@szepeviktor
Copy link

$ parallel-lint --blame --exclude vendor/ .
PHP Fatal error:  Uncaught Error: Class 'JakubOnderka\PhpParallelLint\Application' not found in /home/viktor/.composer/vendor/php-parallel-lint/php-parallel-lint/parallel-lint:62
Stack trace:
#0 {main}
  thrown in /home/viktor/.composer/vendor/php-parallel-lint/php-parallel-lint/parallel-lint on line 62
@jrfnl
Copy link
Collaborator

jrfnl commented Mar 23, 2020

Loosely related to #1 and #9

@grogy
Copy link
Member

grogy commented Mar 25, 2020

Info about solution a problem is on #2 (comment)

@szepeviktor
Copy link
Author

szepeviktor commented Mar 25, 2020

Thank you.
Wouldn't it be nice if it would just work ©️ ?

@grogy
Copy link
Member

grogy commented Mar 25, 2020

I did something bad? I don't see you PR here or in previous repository.

@szepeviktor
Copy link
Author

I did something bad?

No, not at all.

I don't see you PR here or in previous repository.

I'm not involved in the development.

@szepeviktor
Copy link
Author

There must be popular packages/boilerplates for PHP CLI tools!

@mfn
Copy link

mfn commented Mar 26, 2020

Same issue since I moved from the abandoned package (pre 1.0) to this one.

Problem is this order here

getcwd() . '/vendor/autoload.php',
getcwd() . '/../../autoload.php',
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../../autoload.php',
__DIR__ . '/../../autoload.php',

If favours autoloading from the current execution directory.

To me this feels kind of odd, when I run the vendor/bin/parallel-int, it should always use the autoloader from within that installation directory (I installed it via composer).

I.e. I would propose this order instead:

$autoloadLocations = [
    __DIR__ . '/vendor/autoload.php',
    __DIR__ . '/../vendor/autoload.php',
    __DIR__ . '/../../../autoload.php',
    __DIR__ . '/../../autoload.php',
    getcwd() . '/vendor/autoload.php',
    getcwd() . '/../../autoload.php',
];

Not sure what scenarios would require (or even prefer) getwcwd anyway, maybe some out-of-composer manual installation approach?

Reason:

  • I've an installation in ./app/Vendor (cakephp2, don't ask)
  • running it from ./ which has another (different) composer installation
  • 💥

Not a big issue likely, I'll work it around on my end somehow probably.

@grogy
Copy link
Member

grogy commented Apr 1, 2020

Thank you for your comment. I think about why is getcwd necessary.

Commit what added it:

I speculate about removing lines from code:

    getcwd() . '/vendor/autoload.php',
    getcwd() . '/../../autoload.php',

See here somebody a reason why let lines in codebase?

@szepeviktor
Copy link
Author

szepeviktor commented Apr 1, 2020

@mfn
Copy link

mfn commented Apr 1, 2020

See here somebody a reason why let lines in codebase?

Not really, we would need to ask the original author.

If this package is supposed to run via composer, then I think it's safe to nuke them even.

Changing the order might be possible but if left in I would suggest to understand why; removal is easier 😄

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

No branches or pull requests

4 participants