Flash Messages in CakePHP 4 – DerEuroMark
DRANK

This replaces the old and outdated v2+ article about this topic.Looking back at v3As the old article was still from CakePHP 2 days, the CakePHP 3 version was already its own plugin.It was moved to a standalone Flash plugin and further enhanced with for example AJAX handling by including them in the header.You could already directly use the following 4 types:->success() (+ transientSuccess())->info() (+ transientInfo())->warning() (+ transientWarning())->error() (+ transientError())So what’s new in 2020In the new CakePHP 4 version (v2 of the plugin), we can now also work with the Flash component more easily.Especially regarding AJAX it now has a key change included, that really makes quite the difference here:In that case, it doesn’t write to session anymore but serves the messages completely through the built-in transient approach.Let me explain that now a bit more in the next paragraph.Next or Same RequestThis is the key question you need to ask yourself.If you want to persist a fl…

dereuromark.de
Related Topics: PHP Adobe Flash