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 9148449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:16:35+00:00 2026-06-17T11:16:35+00:00

I have a service layer in my Zend Framework 2 application. In this layer,

  • 0

I have a service layer in my Zend Framework 2 application. In this layer, I have an abstract base class which all service classes extend, like demonstrated below.

Base class:

namespace User\Service;

use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceManager;

class AbstractService implements ServiceManagerAwareInterface {
    protected $serviceManager;

    public function setServiceManager(ServiceManager $serviceManager) {
        $this->serviceManager = $serviceManager;
    }

    public function getServiceManager() {
        return $this->serviceManager;
    }
}

A service class:

namespace User\Service;

use User\Service\AbstractService;

class UserService extends AbstractService {
    public function register($id, $username, $password) {
        /* ... */
    }
}

The thing is that the base class will be used throughout my modules (each module will have a service layer) and I am wondering where the best place to store it is. I have exactly the same scenario for my database layer. Off the top of my head, I can think of a few possibilities:

  1. A copy in every module. Not an elegant solution and not easy to maintain.
  2. One copy in an “Application” module and each module uses this one copy. Creates cross-module dependencies.
  3. In the vendor directory and thus outside of any module directory. I am not too familiar with Composer yet, but I guess I could add it as a dependency there?

So basically the question is where to place classes that are used by several modules. It is not difficult to get it to work, but the problem is doing it the best possible way.

  • 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-17T11:16:36+00:00Added an answer on June 17, 2026 at 11:16 am

    I think a good practice is unit all of your base classes and functions into a independent common module, your other modules will depend on this common module.

    There are a lot references you could take a look:

    • PhlyCommon, which PhlyBlog depended
    • ZfcBase, which Zfc series modules depended

    After you have a common module, you could define the module depending relationships by composer, then just one line command to install all depend modules.

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

Sidebar

Related Questions

I currently have service classes that look something like this public class UserService :
I have a service-layer Interface that extends from a base Interface; I would like
I have this sort of format asp.net MVC View -> Service Layer -> Repository.
I have a service, business and data access layer. In which layer should I
I am starting an application built on zend framework; this application should be able
I have a service layer that I would like to convert into a webservice.
I am using declarative transactions in Spring. I have a service layer which is
I have a WCF service layer in my application that passes DTOs to UI.
I have a method in service layer which does the update functionality to database.
I have a service layer that exposes a method, which returns me a List,

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.