How to declare constants to access in modules, controllers, services and others? Zend Framework 3
If you mean constants literally, just put them in class and you can use them anywhere, for example:
namespace Logic\User;
class Type
{
const ADMIN = 1;
const EDITOR = 2;
const READER = 3;
}
Use:
$userType = \Logic\User\Type::ADMIN;
If you understand constants as global, reusable values, try to put them in ZF3 configuration .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.