Codeigniter, Web Development
Hello Friends,
Welcome to Part 32 of the CodeIgniter 4 Tutorial Series in Urdu/Hindi. Today in this CodeIgniter Video Tutorial, We are going to learn how to use Autoload file for Autoloading Libraries without using Composer.
Every application consists of a large number of classes in many different locations. The framework provides classes for core functionality. Your application will have a number of libraries, models, and other entities to make it work. You might have third-party classes that your project is using. Keeping track of where every single file is, and hard-coding that location into your files in a series of requires() is a massive headache and very error-prone. That’s where autoloaders come in.
CodeIgniter provides a very flexible autoloader that can be used with very little configuration. It can locate individual non-namespaced classes, namespaced classes that adhere to PSR4 autoloading directory structures, and will even attempt to locate classes in common directories (like Controllers, Models, etc).
For performance improvement, the core CodeIgniter components have been added to the class-map.
The autoloader works great by itself, but can also work with other autoloaders, like Composer, or even your own custom autoloaders, if needed. Because they’re all registered through spl_autoload_register, they work in sequence and don’t get in each other’s way.
The autoloader is always active, being registered with spl_autoload_register() at the beginning of the framework’s execution.