Using source folders and namespaces
You might have noticed the two configurations autoload
and autoload-dev
These allow us to configure folders of source code in our module and map them to specific base namespaces. You hopefully recall that we discussed this topic in Chapter 10, Composer For Dependencies. However, it is worth mentioning again, because you need to get these autoload sections configured correctly with the namespace for your code.
For example, this file is located in the src
folder and so has the namespace defined as YourName\HelloWorld
:
composer-module-hello-world/src/MessageProviderInterface.php
Repo: https://git.io/JRw54
<?php declare(strict_types=1); namespace YourName\HelloWorld; interface MessageProviderInterface { /** * Get the hello world message in the configured Language */ public function getMessage(): string; }
This test file is located in the...