--- layout: default ---

Yet Another PHP Enum (yape) is a type-safe, object-backed enum implementation in userland PHP. The functionality of yape is split into three different packages:

cspray/yape

The core package that provides the Enum interface and EnumTrait that provides the functionality powering your enum.

cspray/yape-cli

A Symfony Console tool that allows you to easily generate yape Enum and Doctrine Types using a simple command-line interface.

cspray/yape-dbal

An extension of yape that allows you to create Doctrine Types that persist your `Enum` instances using Doctrine.

Installation

We recommend using Composer to install this library. We also highly recommend installing the CLI tool as a development requirement. If you need Doctrine support you should require yape-dbal.

composer require cspray/yape
composer require --dev cspray/yape-cli
composer require cspray/yape-dbal  # if needed for Doctrine support

The rest of this guide will assume you have the yape-cli tool installed.

Getting Started

Tutorials
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 yape 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.