Zend Questioner
Zend Questioner

Reputation: 19

How to shorten Class name in zend

How can I shorten class name in Zend?

For example, in Zend, one should name the model like this: class Application_Model_GuestbookMapper

Because Zend uses autoloader.so how can I short the class name to somethign like: class GuestbookMapper

Upvotes: 0

Views: 100

Answers (1)

MaxSan
MaxSan

Reputation: 318

This is the use of Namespaces. If a namespace is defined within a file as using Application_Model then a class can instantiate GuestbookMapper directly without the entire namespace.

Please note version of PHP must be greater than or equal to 5.3 to support this feature.

More information can be found in the PHP official documentation here:

http://php.net/manual/en/language.namespaces.php

Should probably note this is supported in ZF2 but ZF1 it is not so simple, there is more information about this here:

How do I use namespaces with Zend Framework?

Upvotes: 2

Related Questions