Yet Another PHP Enum (YAPE) is a PHP 7+ code generator designed to provide a type-safe, object-backed enum implementation. While there are many existing PHP enum implementations they almost all boil back to some scalar value in a constant and this isn't the type of enum provided by YAPE. The API for generated enums is inspired by Java and if you have worked with Java enums the objects provided by YAPE will feel familiar, if slightly more verbose in their implementation.


We recommend using Composer to install this library.

composer require cspray/yape

Beyond the documentation provided you may execute vendor/bin/yape <COMMAND_NAME> --help to get assistance with the operations discussed.

Getting Started

Teaches you how to get started using the library without getting too far into details. Designed to get you up and running with the code generated by YAPE.
How To
As your code changes you'll want to make changes to generated Enums as well. Learn about the most common ways to modify your enum after code generation.

The Enum is your code

Although this library aims to reduce the amount of boilerplate and code generation you need to deal with to start using type-safe enums it is important to remember... the Enum is YOUR code. You should look at the code after it is generated and you should modify the code as your needs may change over time.