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

composer autoload issue #89

Closed
itsonit opened this issue May 19, 2016 · 21 comments
Closed

composer autoload issue #89

itsonit opened this issue May 19, 2016 · 21 comments

Comments

@itsonit
Copy link

itsonit commented May 19, 2016

If the running script is placed in a a subdirectory, it will break the loading of the installed providers.

For ex., including autoload like this
require __DIR__.'../vendor/autoload.php';

produce a fatal error:

PHP Fatal error: Uncaught exception 'UserAgentParser\\Exception\\PackageNotLoadedException' with message 'You need to install the package piwik/device-detector to use this provider' in ..

@ThaDafinser
Copy link
Owner

@itsonit see related issue #61 (comment)

Will be solved when moving to php7 only in the next major. For now

@ThaDafinser
Copy link
Owner

For now you need to disable this check. Because the folder is not correctly "relative"

@itsonit
Copy link
Author

itsonit commented May 20, 2016

thx for your reply. For my purpose it was simple to switch routing from filesystem to programmatic aka url-rewrite.

@ThaDafinser
Copy link
Owner

Nice you found already a workaround 👍

@egorsmkv
Copy link

@ThaDafinser Faced with this problem right now. Can you fix this bug?

@ThaDafinser
Copy link
Owner

@egorsmkv can you show me your directory structure and give more informations?

@egorsmkv
Copy link

@ThaDafinser I add your library to my Yii2 project and get this error.

@ThaDafinser
Copy link
Owner

@egorsmkv you can do a var_dump(getcwd()); exit() right before the Exception is thrown?

@ThaDafinser
Copy link
Owner

I think this could work

if (! file_exists(__DIR__ . '/../../../../' . $this->getPackageName() . '/composer.json') && ! file_exists(__DIR__ . '/../../vendor/' . $this->getPackageName() . '/composer.json')) {
    throw new PackageNotLoadedException('You need to install the package ' . $this->getPackageName() . ' to use this provider');
}

@egorsmkv
Copy link

the fact is that I do not want to put the crutches in the code

@ThaDafinser
Copy link
Owner

ThaDafinser commented Jun 21, 2016

@egorsmkv i asked you for your directory structure and i asked if you could post the output of a debug statement.

If you dont want to give me any information i will stop trying to solve this issue

//note the comment above "I think this could work..." is a side note for a possible fix

@egorsmkv
Copy link

@ThaDafinser basic yii2 structure: https://github.com/yiisoft/yii2-app-basic#directory-structure

Maybe it's worth to check availability of the library through the try / catch?

@ThaDafinser
Copy link
Owner

I found this solution...
https://github.com/mindplay-dk/composer-locator

Need to create a PR soon.

@ThaDafinser
Copy link
Owner

@itsonit @egorsmkv this issue should be fixed now.

Please try out dev-master and tell me if it works composer require thadafinser/user-agent-parser:dev-master

#99

@ThaDafinser
Copy link
Owner

//cc to all forks, which corrected this issue - please try out the latest master 😄

@cedricalfonsi @aurelijusrozenas @palpalani @kallaikoi

@chris-doehring
Copy link

@ThaDafinser When do you plan to release a new version which includes this fix?

@ThaDafinser
Copy link
Owner

@chris-doehring i'm just waiting for a feedback, from 1 or 2 people...

@egorsmkv
Copy link

@ThaDafinser unfortunately, I don't use this library, so I can't test the change.

@chris-doehring
Copy link

@ThaDafinser I tried version 1.4.0 and got the same issue as described above. The current dev-master does fix the issue.

@aurelijusrozenas
Copy link

Yes, seems to be working. Tested on symfony 2.8.

@ThaDafinser
Copy link
Owner

Release v1.5.0 https://github.com/ThaDafinser/UserAgentParser/releases/tag/v1.5.0

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

5 participants