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

Conflict with php open_basedir configuration #1

Open
pgdavidApodis opened this issue Jul 7, 2021 · 7 comments
Open

Conflict with php open_basedir configuration #1

pgdavidApodis opened this issue Jul 7, 2021 · 7 comments

Comments

@pgdavidApodis
Copy link

pgdavidApodis commented Jul 7, 2021

When COMPOSER_VENDOR_DIR is not set (it is not by default), the package generates a php warning, if php open_basedir configuration is set.

Warning: file_exists(): open_basedir restriction in effect. File(/autoload.php) is not within the allowed path(s): (/xxx) in /yyy/vendor/vonage/nexmo-bridge/src/Autoloader.php on line 69

Existance of COMPOSER_VENDOR_DIR should be checked first in src/Autoload.php

private static function getClassLoader() : ClassLoader
{
if (file_exists(getenv('COMPOSER_VENDOR_DIR') . '/autoload.php')) {
    return include getenv('COMPOSER_VENDOR_DIR') . '/autoload.php';
}
if (file_exists(__DIR__ . '/../../../autoload.php')) {
    return include __DIR__ . '/../../../autoload.php';
}
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
    return include __DIR__ . '/../vendor/autoload.php';
}

throw new RuntimeException('Cannot detect composer autoload. Please run composer install');
}

First check should be replaced with :

if (getenv('COMPOSER_VENDOR_DIR') && file_exists(getenv('COMPOSER_VENDOR_DIR') . '/autoload.php'))
@natsumework
Copy link

I meet the same problem.

@sca1235
Copy link

sca1235 commented Aug 6, 2021

Same issue

@KRens
Copy link

KRens commented Apr 6, 2022

+1 Same issue.
Your solution fixes it, someone please merge this in.

@nawidhaidari
Copy link

Hello KRens,
how did you users/change this to get it working.
I have this error AH01071: Got error 'PHP message: PHP Warning: file_exists(): open_basedir restriction in effect. File(/autoload.php) is not within the allowed path(s): (/var/www/vhosts/MySite.com/:/tmp/) in /var/www/vhosts/MySite.com/httpdocs/vendor/vonage/nexmo-bridge/src/Autoloader.php on line 69', referer: https://mysite.com/
and dont know how to get this fixed if you could please help.

Thank you,

@KRens
Copy link

KRens commented Dec 26, 2022

THe first post written by pgdavidApodis contains the solution already.
Just replace 1 line of code in src/Autoload.php:

if (file_exists(getenv('COMPOSER_VENDOR_DIR') . '/autoload.php')) {
with:
if (getenv('COMPOSER_VENDOR_DIR') && file_exists(getenv('COMPOSER_VENDOR_DIR') . '/autoload.php')) {

@nawidhaidari
Copy link

Thank you @KRens. It did the trick. I added it to the autoloader.php because there were no if conditions in autoload.php.

@LucaRed
Copy link

LucaRed commented Feb 15, 2023

This has been fixed by #2, so the issue can be closed.

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

6 participants