0

I am trying to load my inner classes via composer too. However it gives me errors. What am I missing here

namespace XYZ;
include('Vendor/autoload.php');

if (Configuration\Config::DEBUG_ENABLED) {
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
}

$config = new Configuration\Config();
$config->createContainer();

echo "Setup Done";
exit();

My composer has

"require": {
        "php": "^7.4"
    },
    "autoload": {
        "psr-4": {
            "XYZ\\": "code-live/"
        }
    },
    "require-dev": {
        "phpunit/phpunit": "^9.6"
    }

My configuration class is

namespace XYZ\Configuration;

class Config{
    const DEBUG_ENABLED = true;    

    private $config;
    
    function __construct() {
        $file = file_get_contents('config.json');
        $this->config = json_decode($file);       
    }
    
    public function createContainer() {                
        $builder = new DI\ContainerBuilder();
        //$builder->...
        return $builder->build();
    }
}

However I get this error

[05-Aug-2023 21:38:03 Europe/Tallinn] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/\Configuration\Config.php) is not within the allowed path(s): (c:/srv/data/www/code-live;c:/windows/temp) in C:\srv\data\www\code-live\Vendor\composer\ClassLoader.php on line 507
[05-Aug-2023 21:38:03 Europe/Tallinn] PHP Fatal error:  Uncaught Error: Class 'XYZ\Configuration\Config' not found in C:\srv\data\www\code-live\index.php:6
Stack trace:
#0 {main}
  thrown in C:\srv\data\www\code-live\index.php on line 6
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193

0 Answers0