mezzio / mezzio-flash Goto Github PK
View Code? Open in Web Editor NEWFlash messages for PSR-7 and PSR-15 applications using mezzio-session
Home Page: https://docs.mezzio.dev/mezzio-flash/
License: BSD 3-Clause "New" or "Revised" License
Flash messages for PSR-7 and PSR-15 applications using mezzio-session
Home Page: https://docs.mezzio.dev/mezzio-flash/
License: BSD 3-Clause "New" or "Revised" License
Q | A |
---|---|
QA | yes |
As decided during the Technical-Steering-Committee Meeting on August 3rd, 2020, Laminas wants to implement vimeo/psalm in all packages.
Implementing psalm is quite easy.
psalm.xml
in the project root$ composer require --dev vimeo/psalm
$ vendor/bin/psalm --set-baseline=psalm-baseline.xml
static-analysis
with the command psalm --shepherd --stats
script:
in .travis.yml
: - if [[ $TEST_COVERAGE == 'true' ]]; then composer static-analysis ; fi
phpstan.neon.dist
, .travis.yml
entry, composer.json
require-dev
and scripts
)Currently, the key of the message is probably mainly used for the corresponding category "warning, info, danger, success". However, if you now have two forms in the page, the evaluation of this information and the output is a bit tricky. It would be nice if you can add the corresponding form name in addition to the key.
currently:
$flashMessages->flash('danger', 'You need to supply your email address');
suggestion:
$flashMessages->flash('danger', 'You need to supply your email address', 'form-name'); // OR
$flashMessages->flash('form-name:danger', 'You need to supply your email address');
$flashMessages->getFlashByForm('form-name');
What do you all mean?
Originally posted by @mano87 at zendframework/zend-expressive-flash#10
Q | A |
---|---|
New Feature | yes |
To be prepared for the december release of PHP 8.0, this repository has some additional TODOs to be tested against the new major version.
In order to make this repository compatible, one has to follow these steps:
composer.json
to provide support for PHP 8.0 by adding the constraint ~8.0.0
composer.json
to drop support for PHP less than 7.3composer.json
to implement phpunit 9.3 which supports PHP 7.3+.travis.yml
to ignore platform requirements when installing composer dependencies (simply add --ignore-platform-reqs
to COMPOSER_ARGS
env variable).travis.yml
to add PHP 8.0 to the matrix (NOTE: Do not allow failures as PHP 8.0 has a feature freeze since 2020-08-04!)Q | A |
---|---|
New Feature | yes |
RFC | no |
BC Break | no |
In my own middlewares I like to add a static method in the Middleware to fetch the respective instance from the reqeust. This way I don't have to check everytime if the return is null
and also don't have to manually assign the type for my IDE. For the FlashMessageMiddleware
that would look something like that:
public static function flashMessages(ServerRequestInterface $request): FlashMessages
{
return $request->getAttribute(self::FLASH_ATTRIBUTE);
}
If the middleware has not been processed in the pipeline, a TypeError
is thrown, so I can be sure I'll always get the correct object.
The problem with the current implementation of the FlashMessageMiddleware
is, that you can set a custom attributeKey
, so that complicates it a little bit (in my middlewares the attribute constants are private, so the only "official" way to fetch the object from the Request is via the static method). That could be mitigated in providing an optional second (deprecated?) parameter for the static method. Why did you event allow setting a custom attribute key?
Would you be open for such a change or should I keep using my own wrapper for this middleware?
Messages set with flashNow()
persist beyond the current request. I found this surprising and inconvenient, but feel like maybe it's intended. So I'll explore it here and suggest some potential changes.
Messages added via flashNow()
are visible immediately, in the request in which they're added, and again in the subsequent request. Note that this does not contradict the documentation, which says:
When you create a flash message, it is available in the next request, but not the current request. If you want access to it in the current request as well, use the flashNow() method instead of flash():
(Emphasis mine)
If this is in fact the expected behavior, I'm somewhat astonished.
Implement the fairly common pattern of a form submission that redirects on success, but re-renders the form in the response to the POST on error. Use flashNow()
in the error branch to display a message in the response (relying on the default $hops = 1
) argument value). Resubmit the form so that the submission succeeds, and and the response redirects the user. Note that the error-info set via flashNow()
is now displayed a second time.
I'd expect messages set with flashNow()
to be visible exclusively in the current request, at least by default.
A strongly-opinionated change would be to simply remove the call to $this->flash(...)
in the flashNow()
implementation (and remove the $hops
argument from flashNow()
as well, I suppose).
A more flexible fix would be to allow flash()
to accept a $hops
of zero, and change the default for flashNow()
to zero $hops
.
Unfortunately, both of those options break BC. A BC-preserving fix would be to simply allow zero $hops. Then users of the class could at least get the behavior they'd like out of the implementation.
As it stands now, I had to "write" my own implementation of FlashMessagesInterface
that behaves as I'd expect. But that implementation was "copy FlashMessages
and remove one line", which feels dirty and makes me sad.
Finally, I'll say that I feel like I'm probably missing some obvious use-case where the current behavior is expected. If someone enlightened me, my consternation might evaporate.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These problems occurred while renovating this repository. View logs.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
composer.json
php ~8.1.0 || ~8.2.0 || ~8.3.0
mezzio/mezzio-session ^1.0
psr/http-server-middleware ^1.0
laminas/laminas-coding-standard ~2.5.0
phpunit/phpunit ^10.2.2
psalm/plugin-phpunit ^0.19.0
vimeo/psalm ^5.13.1
.github/workflows/continuous-integration.yml
.github/workflows/docs-build.yml
.github/workflows/release-on-milestone-closed.yml
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.