This week I have been experimenting a bit with PHP some new approaches I learned with Node.js and GOlang. Trying to follow a “frameworkless” philosophy I tried to expand the functionality of the chosen router library to add the use of middleware and manage the request and response information using representative classes, such as express or fastify.
At the moment I have created a couple of simple middleware. The first intercepts and allows you to manage requests to static files, specifying a specific directory where to locate them. With the second I tried to create automated management of a user session through the use of JWT on cookies; this approach should replace the use of PHP sessions that rely on disk files in the server and session cookies, but I am also thinking of using authorization headers to expand the functionality of the middleware to API calls from SPA as well.
Being quite rusty with PHP I had to add a log manager to log critical and non-critical errors.
The list of libraries has evolved as follows:
- JWT: lcobucci/jwt (New Entry)
- Logging: Monolog (New Entry)
- Env Vars: PHPdotenv
- Routing: FastRoute
- MySQL Client: MeekroDB
- Template: Twig
- Unit Test: PHPunit
I am considering whether to start a small concrete project that I have been thinking about for some time; I think it may be the best way to explore more concrete aspects of development. At the moment I have to say that PHP with version 8 has really modernized, but never as much as TypeScript 4.
“My Little Framework” evolves.