cakedone / cakephp-api-flash
CakePHP 3 plugin that adds any flash message to the response.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=5.4.45
- cakephp/cakephp: ~3.0
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2025-03-01 20:55:50 UTC
README
This plugin consists of only a component to be used in your controllers in order to set flash message in the serialized response.
Usage
Load the component in the desired controller:
# the initialize method $this->loadComponent('ApiFlash');
Then just call the ApiFlashComponent#set(key, message)
method from any controller method:
$this->ApiFlash->set('success', 'You were successfully authenticated!')
It will simply add an array to the flash
key in the response body:
[ 'flash' => [ 'success' => 'You were successfully authenticated!' ] ]
Config
You can configure the key which the array will be set in the response. Simply add a key
index to the config of loadComponent
call:
# the intialize method $this->loadComponent('ApiFlash', ['key' => 'feedback']);