Computing Magazine

Create Service Class in PHP with Zend Framework

Posted on the 31 July 2012 by Akahgy


Communicate between modules in MCV architecture like PhP’s Zend Framework.


Communication between modules, in MCV architecture should not be done directly by calling the model class, but accessing a service class assigned to the model.

A service class represents the mirror image of the original model class.

Name of class: class ModuleName_Service_ClassName

Parameters: private $_model;

Methods: protected function _getModel()

After this previous requirements the model methods are described, just with function name and return value.


class Customer_Service_Address {

  private $_model;

  protected function _getModel() {
  $this->_model = new Customer_Model_Address();
  return $this->_model;

  public function updatePostcode($postcode) {
  return $this->_getModel()->updatePostcode($postcode);


Back to Featured Articles on Logo Paperblog