Replies: 1 comment 4 replies
-
This thing is massive and it looks quite strong. Thanks for sharing! :) I started looking at the docs. docs/1.router.mdI have a question for understanding your docs/1.router.md You try to create a server. If that does not work you yield an error. This part is fine. But why is you main() even trying to then define a route afterwards? You will never be able to run it anyways. For me this makes no sense at all. Not being able to create a server is a fatal error situation. If you want to stay true to your logic I would not just yield the error but also return void to get out of the error generator. Your error management mechanic is a really cool idea. We do something alike - sometimes. In this case I think throwing a fatal error could be a better option... But I haven't looked at the outer context yet. Do you lack type declaration here? It feels like boilerplate having to write: // 1. Open file
$fileAttempt = File::open('file.txt');
if ($fileAttempt->error){
return error($fileAttempt->error);
} When calling a main() you could expect a fatal error to be thrown and catch it outside (via middleware?). This would make writing code much slimmer and prevent to continue after an unrecoverable situation. But I think you prefer each route to be able to do its own thing in handling situations without having to throw. Option AttributeThe idea of the Option Attribute is sexy. :D EnvironmentServiceEnvironmentService::setFileName can be removed if you extend your constructor to allow a second parameter. public function __construct(
private readonly LoggerInterface $logger,
private readonly string $fileName = './env.yaml',
) {
} You even could go hardcore ("defaults are stored as null for maximum flexability") and use null (and allow null) as default and set the default in line 69: $fileName = $this->fileName ?? './env.yaml'; But that reduces readability in this case. composer scriptsI would love to see you using a Makefile instead of composer scripts for readability. I will continue reading the code. |
Beta Was this translation helpful? Give feedback.
-
Chitchat, brainstorming and experiences, all welcome here.
Beta Was this translation helpful? Give feedback.
All reactions