Giter Site home page Giter Site logo

Comments (6)

franzliedke avatar franzliedke commented on May 17, 2024 1

If PR #17 gets merged, all you will need to do is provide another implementation of Aidantwoods\SecureHaders\Http\HttpAdapter. :)

from secureheaders.

franzliedke avatar franzliedke commented on May 17, 2024 1

PR #21 was merged - this will be in v2.0. :)

from secureheaders.

aidantwoods avatar aidantwoods commented on May 17, 2024

Would this be so that SecureHeaders communicates with the PSR-7 defined interfaces, or an adapter for it to be the PSR-7 defined interface?

from secureheaders.

prisis avatar prisis commented on May 17, 2024

Like the idea from @franzliedke

Not sure whether this belongs here, but the issue is titled "Usage concerns", so I may as well expand the discussion... The way the library is currently set up, it might be hard to integrate into any modern PHP framework. That's because they typically do not use PHP's global request context methods (such as header and setcookie) directly, but instead operate on various abstractions of HTTP requests and responses.
Most notably, this would probably be PSR-7 requests/responses or the equivalents from Symfony's HttpFoundation component.

So, my first suggestion would be to split the configuration. generation and actual writing of the headers / cookies into separate classes: you'd have a factory that is used for configuring the headers, a class that creates the appropriate HTTP headers and cookies (only the strings) from that configuration, and finally an adapter that actually writes them to either a HTTP response object, or PHP's global functions.
We could then create different adapters for integration with frameworks / other projects: I'd suggest three implementations, for PSR-7, Symfony, as well as the header/setcookie functions

This might seem like overkill, but IMO it would greatly help in a) integratability (I might have made that word up), b) maintainability and c) testability.

And we can use it in all middlewares (PSR-15) ;)

from secureheaders.

aidantwoods avatar aidantwoods commented on May 17, 2024

Yup I definitely like that idea!

Feel free to make a PR 😄

Function you're looking to for is sendHeaders which makes the only two calls to PHPs header function.

from secureheaders.

franzliedke avatar franzliedke commented on May 17, 2024

...meaning this issue can be closed. 😎

from secureheaders.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.