- namespaces are not required for each file/class, but we can use them... optional.
require_once "./app/Email.php";- namespaces are required, it is used to map directories in
composer.json - we do not need
require_oncefor each class - we do need
require_oncefor composer autoload
require_once "./vendor/autoload.php";- Some notes for the composer.json file
-
- current folder
-
-
"namespace1\\": "./folder",
-
-
- Back up 1 dir, OUTSIDE the project, or outside the public_html folder
-
-
"namespace2\\": "../folder",
-
-
- root, usually files in public_html
-
-
"": ".",
-
/*
"autoload": {
"psr-4": {
"MYAPP\\": "./app/",
"MYCORE\\": "./core/",
"": "."
}
},
*/- Make to check in/add both
composer.jsonand `composer.lock' to repo too. - Add vendor to
.gitignore, not need in git repo.
- The Environment I tested this as localhost I created in Windows 11. Local apache server and php