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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:51:34+00:00 2026-05-24T08:51:34+00:00

We are using PHP 5.3 and Zend Framework for a large project, and I’ve

  • 0

We are using PHP 5.3 and Zend Framework for a large project, and I’ve run into a problem of convenience. We reuse the same error messages over and over again in different parts of the application, like “You don’t have permission to complete this action.” Does anyone have any unique ways of reusing error messages so we don’t have to rewrite them over and over again?

My first thought was to do something simple like this:

class ErrorMessage
{
    const ERROR_NO_PERMS = 'noPerms';
    const ERROR_INT = 'int';

    protected static $_messages = array(
        self::ERROR_NO_PERMS => 'You do not have permission to complete this action',
        self::ERROR_INT      => "'%s' must be an integer",
    );

    public static get($errorCode)
    {
        if (!array_key_exists($errorCode, self::$_messages)) {
            // error
        }

        // check for translation

        return self::$_messages[$errorCode];
    }
}

What would you do? (Keep in mind that we would like this to be integrated with ZF, so we are open to any ideas that extend into native ZF classes.)

  • 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-05-24T08:51:35+00:00Added an answer on May 24, 2026 at 8:51 am

    You could also created “named exceptions”.

    class PermissionException extends Exception
    {
      public function __toString()
      {
        return 'You do not have permission!';
      }
    }
    

    If ZF has own exceptions, you can extend those. Or you can extend one of the already available PHP exceptions.

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

Sidebar

Related Questions

I'm trying to create a Zend Framework project using PHP 5.3.2 and Zend Framework
I've built a search index using the PHP Zend Framework Search (based on Lucene).
I am trying to build a Connect app using PHP and the Zend Framework.
I have a PHP MVC application using Zend Framework. As presented in the quickstart,
All, I have a PHP Web application built using Zend Framework and MVC with
I would like to use an IDE for PHP Development using Zend framework &
Hi I'm currently working on some php - zend framework project on my osx
I'm using some Zend libraries outside of the Zend Framework in a small project.
I am using PHP with the Zend-Framework to create emails. How can I mark
Using PHP 5.3 and Zend Framework 1.11.7 I've been trying to configure the AutoLoader

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.