I've been working on a project using the SLIM API framework in PHP, and I'm facing a slight roadblock. I need to find a way to share variables across multiple PHP files, but I want these variables to be specific to each API request.
Let me explain this in a bit more detail. In my project, I have multiple PHP files that handle different API endpoints. Each endpoint requires some common variables, such as user authentication details or configuration settings. However, I want these variables to be unique to each API request.
I've tried using global variables, but they persist across different requests, which is not what I want. I want the variables to be reset or initialized afresh for each request. Is there any way to achieve this?
I've heard about middleware in SLIM API, but I'm not sure if that's the right approach or if it can solve my problem. I'd really appreciate if someone could shed some light on this matter and guide me towards the right direction.
Thanks in advance for your help!