ahmad soliman
ahmad soliman

Reputation: 141

Class 'Album\Controller\AlbumController' not found

When i try to start album application an error message appears:

Fatal error: Class 'Album\Controller\AlbumController' not found in C:\xampp\htdocs\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\ServiceManager\AbstractPluginManager.php on line 170

This is my module.config.php file code

<?php
return array(
    'controllers' => array(
        'invokables' => array(
            'Album\Controller\Album' => 'Album\Controller\AlbumController',
        ),
    ),

    // Added to make router
    'router' => array(
        'routes' => array(
            'album' => array(
                'type' => 'segment',
                'options' => array(
                    'route' => '/album[/][:action][/:id]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id' => '[0-9]+'
                    ),
                    'defaults' => array(
                        'controller' => 'Album\Controller\Album',
                        'action' => 'index',
                    ),
                ),
            ),
        ),
    ),

    'view_manager' => array(
        'template_path_stack' => array(
            'album' => __DIR__ . '/../view',
        ),
    ),
);

And this is AlbumController.php file code:

<?php

namespace Album\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AlbumController extends AbstractActionController {

    protected $albumTable;

    public function indexAction() {
        return new ViewModel(array(
            'album' => $this->getAlbumTable()->fetchAll(),
        ));
    }

    public function addAction() {

    }

    public function editAction() {

    }

    public function deleteAction() {

    }

    public function getAlbumTable () {
        if (!$this->albumTable) {
            $sm = $this->getServiceLocator();
            $this->albumTable = $sm->get('Album\Model\AlbumTable');
        }
        return $this->albumTable;
    }

}

Upvotes: 1

Views: 2467

Answers (1)

Nishchith Uchil
Nishchith Uchil

Reputation: 152

i see you are just getting started, so i would refer to this code by Martin Shwalbe and find out if you have any typo. If everything looks good, then you probably have issue in the way you are accessing it.

https://github.com/Hounddog/Album

hope this helps...

Upvotes: 1

Related Questions