The Yii2 framework contains a special security component that provides a set of methods for handling common security-related tasks. The \yii\base\Security
class requires the OpenSSL
PHP extension instead of mcrypt
.
Create a new application by using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
Set up the database connection and create a table named
order
, as follows:DROP TABLE IF EXISTS `order`; CREATE TABLE IF NOT EXISTS `order` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `client` VARCHAR(255) NOT NULL, `total` FLOAT NOT NULL, `encrypted_field` BLOB NOT NULL, PRIMARY KEY (`id`) );
Generate an
Order
model using Gii.
Add an additional key parameter to
config/params.php
, as follows:<?php return [ 'adminEmail' => '[email protected]', 'key' => 'mysecretkey' ];
Add the
behaviors
andhelper
properties to theOrder
model as follows:public...