How can I load a library in Codeigniter via autoload composer?
This is in fact unrelated to CodeIgniter.
You need to tell composer
that you have your own PHP classes that aren't among autoloaded files.
In your composer.json
add one of these:
{ // ... "autoload": { "psr-4": { "MyNamespace\\": "src/library/MyNamespace" }, "files": ["src/some/custom/filepath.php"] }}
Then run in console update
to update autoload.php
with your new config:
$ composer update
Now every time you use a class from MyNamespace
such as MyNamespace\MyClass
it'll look for file src/library/MyNamespace/MyClass.php
.
Also, file src/some/custom/filepath.php
is always included automatically so you don't need to include it manually. (I don't know what's your usecase).
See for more info: https://getcomposer.org/doc/04-schema.md#autoload
Do you have added it in autoload.php
$autoload['libraries'] = array('pager');