Class Album\Module contains 1 abstract method

Hi everyone,

I am folllowing the tutorials “Getting Started with Laminas MVC Applications” and after completing the major steps to get a view, I have an error message:

**Fatal error** : Class Album\Module contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Laminas\ModuleManager\Feature\ConfigProviderInterface::getConfig) in  **C:\xampp\htdocs\laminas-mvc-tutorial\module\Album\src\module.php**  on line  **11**

Here is my module.php file:

<?php

namespace Album;

// Add these import statements:
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Db\ResultSet\ResultSet;
use Laminas\Db\TableGateway\TableGateway;
use Laminas\ModuleManager\Feature\ConfigProviderInterface;

class Module implements ConfigProviderInterface
{
    // getConfig() method is here

    // Add this method:
    public function getControllerConfig()
    {
        return [
            'factories' => [
                Controller\AlbumController::class => function($container) {
                    return new Controller\AlbumController(
                        $container->get(Model\AlbumTable::class)
                    );
                },
            ],
        ];
    }
    
    // Add this method:
    public function getServiceConfig()
    {    	
        return [
            'factories' => [
                Model\AlbumTable::class => function($container) {
                    $tableGateway = $container->get(Model\AlbumTableGateway::class);
                    return new Model\AlbumTable($tableGateway);
                },
                Model\AlbumTableGateway::class => function ($container) {
                    $dbAdapter = $container->get(AdapterInterface::class);
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Model\Album());
                    return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
                },
            ],
        ];
    }
}

I should have followed every step. So what?

As far as the section Modules is concerned, here is my contribution.

I’ve run into problems that I could solve on my own, adding <?php at the top of following files: module.php, module.config.php, AlbumController.php

In module.config.php addition to the existing file should be completed with use Laminas\Router\Http\Segment;

Hello and welcome to the forums! :smiley:

If I understand correctly then you copied the entire content for the module class from the tutorial. If this is how you’ve been acting then you have overwritten the previous content.

The method getConfig was added in the previous step “Setting up the Album module”:

namespace Album;

use Laminas\ModuleManager\Feature\ConfigProviderInterface;

class Module implements ConfigProviderInterface
{
    public function getConfig()
    {
        return include __DIR__ . '/../config/module.config.php';
    }
}

The framework, the components and the documentation are aimed at experienced PHP users therefore the PHP tags are omitted and only present in examples for view / template scripts. But we want to provide the whole code in a new tutorial.

The import of the classname exists in the related code example of “Routing and controllers”:

namespace Album;

use Laminas\Router\Http\Segment;
use Laminas\ServiceManager\Factory\InvokableFactory;

// …

I hope your problem can be solved and thanks for your feedback!

1 Like

Hello froshdesign!

That’s too bad I skipped a part of the previous steps and asked for help just because I did’nt open my eyes. It works very well now!

Regarding the comments I made, it’s just that I checked the result in my browser before I complete the routing and the controller part. And I solved the errors I had at this stage.

Thanks a lot for your time and this wonderful stuff!