We redo the module structure to use a src directory and make plans to add a service class.
The first thing we’ll do is restructure the directory, so we have our module source code in a src
directory. This is a common pattern you’ll see in plugins so let’s follow that. This isn’t necessary — and our code will still functioning just fine without it — but will also be an easier transition to developing plugins for Craft CMS when the time comes for that.
After changing the location our module class file, we need to let Composer know about that and then rebuild the autoload files.
My First Craft CMS Module is made up of the following videos: