In this recipe, we will explore how to use model events to tie additional data to our models outside of the normal database service layer. The approach in this recipe can be adapted to handling file uploads, sending e-mails, or any other activity that exceeds the typical store everything in the database technique.
This recipe uses its own database schema and the Phalcon Developer Tools, which we will use to set up a CLI project skeleton. This project will require command line usage.
This recipe requires the gmp
PHP extension.
This recipe will use the openssl_random_pseudo_bytes
function to create UUIDs (Universally Unique Identifiers), and so you will need to ensure that this is enabled in the PHP configuration. On Linux and OSX, this should already be enabled but on Windows, with environments like WAMP, it may require manually enabling it in the php.ini
file and then restarting the web server.