4 ms·
I remember working with PHP and initially being impressed by its simplicity but quickly being overwhelmed by its restrictiveness. I could tell that there was s
by commandlinefan 5y ago
I remember working with PHP and initially being impressed by its simplicity but quickly being overwhelmed by its restrictiveness. I could tell that there was some sort of higher level of abstraction that could make it more maintainable long term - I even came up with some simplifications of my own that made routine maintenance easier (for me). The problem I've seen is that everybody else had the same thought and came up with their own "simplifications" that they did a much better job of marketing than they did of marketing and now we're stuck using their "frameworks" because to do otherwise invites accusations of "wasting time reinventing the wheel".
- tored 5y agoWhat is nice is that it easier than ever to write minimal framework, somethings I think you should accept, like using composer and some of the common libraries, however bootstrapping is something I prefer to do myself. I'm having a renaissance with minimal PHP framework. My current iteration looks something like this, and it is only a few functions to do it (I do use a router library, no point of reinventing that) return #[Route(method: 'GET', route: '/projects/{project_uid}/edit')] #[Template(path: __DIR__ . '/template/template.php)] function (Request $request, ProjectRepository $projectRepository) { $projectUid = ProjectUid::of($request->vars['project_uid'] ?? ''); if ($projectUid === null) { return [__DIR__ . '/../errorView.php', [400, 'Missing project_uid']]; } $project = $projectRepository->getProjectByProjectUid($projectUid); if ($project === null) { return __DIR__ . '/../notFoundView.php'; } ?> <div class="container"> <h1><?= escape($project->title) ?></h1> </div> <?php }; Attributes is huge imporovemt to writing a small framework, attributes can not only be used for help setting up routing, HTML templating but other things as middlewares, output buffering, dependency injection. I think we should resist the takeover of large frameworks, and the thing is if you are architecting your application properly, it should be framework independent anyway. Unfortunately many ideas in large frameworks makes it harder or at least invites the developer to make the framework takeover the application.