I've been working on setting up a CodeIgniter project with composer. I'm wanting to include php
classes stored in files outside the vendor
folder - in a shared
folder.
My directory structure:
/
--application/
--shared/
-application/
-class1.php
-class2.php
-class3.php
-base/
-classb1.php
--vendor/
--composer.json
--composer.lock
Looking at the composer documentation , I see there is an autoload
property in the root package that I'm trying to use to load the classes in the shared
directory. These classes aren't namespaced.
My composer.json
file is as follows:
{
"description" : "The CodeIgniter Application with Composer",
"require": {
"php": ">=5.3.2",
"codeigniter/framework": "3.1.*"
},
"require-dev": {
"mikey179/vfsStream": "1.1.*"
},
"autoload":{
"psr-0":{
"":"shared/application/",
"":"shared/base/",
"":"shared/data/"
}
}
}
My search led me to this question , but the classes are still not being loaded. I've ran composer update
on the terminal.
Well after looking further, there's a property called classmap
( documentation ) in the root package.
"autoload":{
"classmap":["shared/application/","shared/base/", "shared/data/"]
}
This loads all the required files in the folders.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.