Composer自动加载器不加载类

I am building a tiny vanilla PHP application and need to implement an autoloader into the functionality as I want to ensure my application is coded in a clean and efficient manner. I have decided to use Composer for it's built in autoloading functionality and have installed this and created a composer.json file. I then ran:

composer install

I have a class that is namespaced under lib\DB as follows:

<?php

namespace lib;

class DB
{
.....

And am attempting to call this namespaced class using:

 include_once('config.php');

    use lib\DB;

    function addProducts() {
        try {
            $db = DB::getInstance();
            $connection = $db->getConnection();

This is throwing an error saying:

Fatal error: Uncaught Error: Class 'lib\DB' not found in /var/www/php-parser/index.php on line 9

I can see the autoload.php files has been generated inside the vendor folder so this is all ok. Is there something I have forgotten to do?

Thanks