Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9082435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:33:27+00:00 2026-06-16T20:33:27+00:00

I’m trying to create a Zend Framework 2 module that has some generic classes

  • 0

I’m trying to create a Zend Framework 2 module that has some generic classes that I want to use in some of my controllers.

I created a directory called ‘tux-drink-zf2-module’ in ‘vendor’ directory.

I added that directory to ‘application.config.php’.

my Module.php has the following:

<?php

namespace TuxDrink;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;

class Module implements AutoloaderProviderInterface
{
public function getAutoloaderConfig()
{
    return array(
        'Zend\Loader\ClassMapAutoloader' => array(
            __DIR__ . '/autoload_classmap.php',
        ),
        'Zend\Loader\StandardAutoloader' => array(
            'namespaces' => array(
                __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
            ),
        ),
    );
}
}

update

new:

my autoload_classmap.php has the following:

<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
'TuxDrink\Module'                                  => __DIR__ . '/Module.php',
'TuxDbCassandra'                                   => __DIR__ . '/src/TuxDrink/TuxDb/Cassandra/TuxDbCassandra.php',
'TuxDrink\Drink\Model\AlcoholSum'                  => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/AlcoholSum.php',
'TuxDrink\Drink\Model\AlcoholSumTable'             => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/AlcoholSumTable.php',
'TuxDrink\Drink\Model\Drink'                       => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/Drink.php',
'TuxDrink\Drink\Model\DrinkBrand'                  => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkBrand.php',
'TuxDrink\Drink\Model\DrinkBrandTable'             => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkBrandTable.php',
'TuxDrink\Drink\Model\DrinkCompany'                => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkCompany.php',
'TuxDrink\Drink\Model\DrinkCompanyTable'           => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkCompanyTable.php',
'TuxDrink\Drink\Model\DrinkFlavor'                 => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkFlavor.php',
'TuxDrink\Drink\Model\DrinkFlavorTable'            => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkFlavorTable.php',
'TuxDrink\Drink\Model\DrinkFlavorType'             => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkFlavorType.php',
'TuxDrink\Drink\Model\DrinkFlavorTypeTable'        => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkFlavorTypeTable.php',
'TuxDrink\Drink\Model\DrinkIngredient'             => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkIngredient.php',
'TuxDrink\Drink\Model\DrinkIngredientTable'        => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkIngredientTable.php',
'TuxDrink\Drink\Model\DrinkIngredientType'         => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkIngredientType.php',
'TuxDrink\Drink\Model\DrinkIngredientTypeTable'    => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkIngredientTypeTable.php',
'TuxDrink\Drink\Model\DrinkTable'                  => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkTable.php',
'TuxDrink\Drink\Model\DrinkType'                   => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkType.php',
'TuxDrink\Drink\Model\DrinkTypeTable'              => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkTypeTable.php',
'TuxDrink\Drink\Model\GlobalImage'                 => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImage.php',
'TuxDrink\Drink\Model\GlobalImageLink'             => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageLink.php',
'TuxDrink\Drink\Model\GlobalImageLinkPending'      => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageLinkPending.php',
'TuxDrink\Drink\Model\GlobalImageLinkPendingTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageLinkPendingTable.php',
'TuxDrink\Drink\Model\GlobalImageLinkTable'        => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageLinkTable.php',
'TuxDrink\Drink\Model\GlobalImageTable'            => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageTable.php',
'TuxDrink\Drink\Model\GlobalImageType'             => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageType.php',
'TuxDrink\Drink\Model\GlobalImageTypeTable'        => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageTypeTable.php',
'TuxDrink\Drink\Model\LiquidColor'                 => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/LiquidColor.php',
'TuxDrink\Drink\Model\LiquidColorTable'            => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/LiquidColorTable.php',
'TuxDrink\Drink\Model\LiquidColorType'             => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/LiquidColorType.php',
'TuxDrink\Drink\Model\LiquidColorTypeTable'        => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/LiquidColorTypeTable.php',
'TuxDrink\Drink\Model\PendingDrinkCommits'         => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/PendingDrinkCommits.php',
'TuxDrink\Drink\Model\PendingDrinkCommitsTable'    => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/PendingDrinkCommitsTable.php',
'TuxDrink\TuxDb\Mysql\Drink\TuxDbMysqlDrink'       => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/TuxDbMysqlDrink.php',
'TuxDrink\TuxDb\Drink\Util\AlcoholCalc'            => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Util/AlcoholCalc.php',
'TuxDrink\TuxDb\Mysql\TuxDbMysql'                  => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/TuxDbMysql.php',
'TuxDrink\TuxDb\TuxDbAbstract'                     => __DIR__ . '/src/TuxDrink/TuxDb/TuxDbAbstract.php',
'TuxDrink\TuxDb\TuxDbInterface'                    => __DIR__ . '/src/TuxDrink/TuxDb/TuxDbInterface.php',
'TuxDrink\TuxDb\TuxDrinkInterface'                 => __DIR__ . '/src/TuxDrink/TuxDb/TuxDrinkInterface.php',
'TuxDrink\TuxDb\TuxTableInterface'                 => __DIR__ . '/src/TuxDrink/TuxDb/TuxTableInterface.php',
);

but still when I try to refresh my project I get the following error:

 Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (tux-drink-zf2-module) could not be initialized.' in /Volumes/2g-storage/projects/php-projects/myalcoholist/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php on line 144

maybe i’m missing some other files in order to properly configure this as a Module?
remember, this is a package for sources, without controllers, views and actions.

any information regarding the issue would be greatly appreciated.

update

this issue was solved when i fixed the directories structure.

but when I’m trying to use the module in one the the controllers.

in my case i need to use two classes from the TuxDrink module.

class ‘TuxDbMysqlDrink’ and class ‘TuxDbMysql’.

I need to use them in controller ‘DrinkController’ in action ‘drink-brand-autocomplete’.

I use the following code:

use \TuxDb\Mysql\Drink\TuxDbMysqlDrink;

use \TuxDb\Mysql\TuxDbMysql;


public function drinkBrandAutocompleteAction() {
    $param=$this->getRequest()->getQuery('q');
    if ($param) {
        $drink = new TuxDbMysqlDrink();
        $result=$drink->autoCompleteDrinkBrand($param);
        return $result;
    }
}

and I get the following error message:

 Fatal error: DrinkManagement\Controller\DrinkController cannot use TuxDrink\TuxDb\Mysql\Drink\TuxDbMysqlDrink - it is not a trait in /Volumes/2g-storage/projects/php-projects/myalcoholist/module/DrinkManagement/src/DrinkManagement/Controller/DrinkController.php on line 197

any ideas?

tried to google, couldn’t understand what it means "it is not a trait"

update

resolved it with this code:

public function drinkBrandAutocompleteAction() {
    $param=$this->getRequest()->getQuery('q');
    if ($param) {
        $drink = new \TuxDrink\TuxDb\Mysql\Drink\TuxDbMysqlDrink();
        $result=$drink->autoCompleteDrinkBrand($param);
        die(var_export($result,1));
     ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:33:28+00:00Added an answer on June 16, 2026 at 8:33 pm

    Going by the error, the Module name is tux-drink-zf2-module. Taking sanitization into account, i’ll assume your module is CamelCased like TuxDrinkZf2Module. Therefore the namespace you’re assigning inside Module.php doesn’t match, as it’s only TuxDrink.

    So my guess would be, either of your names is incorrect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.