I am new to the composer and here is my composer.json file:
{
"name": "asd",
"authors": [
{
"name": "test",
"email": "test@me.com"
}
],
"require": {
"vlucas/phpdotenv": "^2.4"
},
"autoload": {
"files": [
"config/bootstrap.php",
"lib/app.php"
],
"classmap": [
"lib/ez_sql/shared/ez_sql_core.php",
"lib/ez_sql/mysql/ez_sql_mysql.php",
"lib/smarty/libs/"
],
"psr-4": {
"App\\" : "app/",
"Sys\\": "system/"
}
}
}
As you can see there is an autoload file config/bootstrap.php
in which I have few classes instances, and I want to access these in other files. But the problem is I can't access until I don't declare as GLOBAL
variable. For Example:
config/bootstrap.php
$obj1 = new obj();
$GLOBALS['obj2'] = new obj2();
I can access $obj2
in other files like in index.php
but can't use $obj1
.
Is there any other possible way to use composer autoload
file variable in other files instead of declaring as global
?