Comments (7)
How would having an all
method that did the same thing as fromRequest
and fromResponse
make it easier to use from a container? I think I'm probably misunderstanding something about how you'd like to see it used.
Right now the easiest way to use this would be to not use them from a container at all as the facade classes are meant to just be used directly (static methods) as the classes don't make sense outside of the context of having a request or response to begin w/.
Perhaps if you could tell me more about your use case / how you would like to use it / how it currently isn't able to do what you'd like I'd be able to better figure out a solution that would make your life easier.
Thanks for the feedback!
from dflydev-fig-cookies.
I'm using Slim PHP 3 and trying to come up with a cookies implementation that will have to be stored inside the container. Using static classes like this in a DI app is bad practice (not preaching to you by any means).
As it currently is, I would have request-cookies
and response-cookies
in the container which return instances of the classes I mention. Then they can be used in object context, not static which fits the design principal at work with Slim.
The only thing missing is the ability to get a package of all the current cookies from the headers in that object context, without making a wrapper class.
from dflydev-fig-cookies.
I see! So the two things you mentioned were completely separate. 1) You like it but it is awkward to use w/ a container and 2) You want an all
method so you can get all of Cookies or SetCookies. Is that correct?
I'd not be opposed to adding some sort of all
method to get all of the Cookies and SetCookies from a request or response. If you want to add it / prototype it and send a PR I'd happily take a look.
I'd probably go w/ getAll
as that maps better with what is inside Cookies
and SetCookies
since both of those classes already have a getAll
method.
from dflydev-fig-cookies.
I hadn't realised that the whole thing was static methods when I wrote the original issue, sorry.
from dflydev-fig-cookies.
Is ok. :) If you'd still like to add a getAll
method for the outermost facades that would be awesome. I think it would be very useful. :) I don't think I'll take it away from being static methods, though.
And to be fair, I think the primitives (Cookie
and SetCookie
) themselves are not entirely static but they are entirely immutable so the mutators return new copies of the objects rather than modifying the object itself (much like PSR-7). That still won't help you much, though. :)
from dflydev-fig-cookies.
entirely immutable
which is why I like this :D
When I get a spare minute or few, I'll put something together. Thanks.
from dflydev-fig-cookies.
Thanks again for the issue. I'm closing this for now as I think that it was resolved (or as resolved as it was going to get) already?
from dflydev-fig-cookies.
Related Issues (20)
- FigRequestCookies::get doesn't respect Path? HOT 1
- Can
- Can
- Not work with Slim 3.5 HOT 3
- Why i'm cannot remove (expire) cookie, if use withPath method?.. HOT 4
- SetCookie::expire does not work: missing Domain part HOT 24
- Problems with urlencode HOT 1
- Can SetCookie's constructor take more arguments? HOT 3
- Slim 3 Middleware returns null for cookies HOT 1
- Creating cookie not generating a cookie file
- Max-Age=0 doesn't removes a cookie on a client
- SameSite, getValue
- SameSite=None - missing release? HOT 1
- PHP8 Support HOT 4
- TypeError on urldecode() with malformed cookie
- can not set request cookie
- Unable to set expiry time... HOT 1
- 3.0.0 missing from Changelog
- url encoding HOT 2
- `FigRequestCookies::get()` not using `ServerRequesInterface::getCookieParams()` ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dflydev-fig-cookies.