2026 Community Survey results are here! See how the Craft CMS community works. results are live!

Module Class Autoloading and Bootstrapping

We make sure our module code will run in the Craft application by updating the Composer autoloader files and adding it to the Craft bootstrap config.

Now we need to make sure Com­pos­er knows about our new mod­ule and where its class­es are. So we have to edit the composer.json  file and add the name­space as a key and then the mod­ule loca­tion as the value.

"autoload": {
	"psr-4": {
		"craftquest\\": "modules/cqcontrolpanel/"
	}
}

After that we need to update the Craft appli­ca­tion con­fig file locat­ed in config/app.php and tell it about our new mod­ule. This will tell Craft about your mod­ule and then, option­al­ly, load it on every request. 

'modules' ['c-q-control-panel' => modules\craftquest\cqcontrolpanel\CQControlPanel::class
],
'bootstrap' => ['c-q-control-panel'],

Instructor
Ryan Irelan
Level
Beginner
Date Published
March 02, 2021
Ryan Irelan

I am the creator of CraftQuest, a web developer, and former software team manager. I spend most of my time improving CraftQuest with code and courses. When I'm not in front of the computer, I spend my time with my family, and running on the roads and trails of Austin, TX.