The CodeIgniter document does not seem to contain namespace. PS: How to use the library loaded by composer in CodeIgniter. The CodeIgniter document does not seem to contain namespace.
PS: How to use the library loaded by composer in CodeIgniter.
Reply content:
The CodeIgniter document does not seem to contain namespace.
PS: How to use the library loaded by composer in CodeIgniter.
CI3 began to support namespaces.
If you want to useComposerYou canconfig/config.phpFile$config['composer_autoload'] = TRUE;This option is changed to TRUE. the default value is FALSE.
Note. If you change it to TRUE, the CI is automatically loaded.application/vendor/autoload.phpSo, if yourvendorThe directory is under the root directory of your project, that isindex.phpSame level, you can use$config['composer_autoload'] = realpath(APPPATH . '../vendor/autoload.php');This way to introduceComposer
Without namespace, the CI framework cannot use namespaces.
But you can use your own code.
If you want to use composer, you can add
require __DIR__.'/vendor/autoload.php';...
Remember to tune the path yourself
If php version is later than 5.3, the namespace is supported. it has nothing to do with the framework.
You only need to useuseKeywords
// Use the fully qualified name of your composer package use Monolog \ Logger; use Monolog \ Handler \ StreamHandler; class TestController {}