Webgamers / ProjectReling

Our second community project
http://webgamers.de/index.php?page=Board&boardID=81
1 stars 1 forks source link

First try of a basic MVC implementation #1

Closed chrischi1989 closed 10 years ago

chrischi1989 commented 10 years ago

I did some work on my personal idea of how a basic MVC structure could be implemented without using a framework. This first idea comes with a PSR-0 autoloader if namespaces should be used and a basic autoloader for the app directory, which keeps the controllers & models in the global namespace. Also a small dependecy injector is included for resolving dependencies injected in the constructor methods inside a controller.

What do you think?

chrischi1989 commented 10 years ago

Well I thought the approach would be discussed before merging / denying it. But otherwise...who gives a shit. I hope it will be improved later on.

LinuxDoku commented 10 years ago

Is there a reason why you use private over protected for "internal" Methods? Could be helpful to override some methods in the Request class. For example when somebody is trying to mock an http request for a test scenario.

chrischi1989 commented 10 years ago

Wouldn't it be better if the behaviour singleton/non-singleton is configurable? With $paramter->getClass()->name you could grab the class by type hint Is there a reason why you use private over protected for "internal" Methods?

  1. I've done it this way to prevent the creation of instances of the same class over and over again. Feel free to modify.
  2. I agree that this would be better. Feel free to modify.
  3. Because I don't test and overwrite methods. Besides this I personally don't think that there will be tests at all because of the "beginner" approach of this project.

Additionally - I just came across "Dice" as a dependecy injector container which uses the same approach (with the reflection api) as I do. Maybe we should consider using Dice for dependencies. Or we could just use a simple registry which would be more understandable for the beginners out there.

LinuxDoku commented 10 years ago

The arguments with tests is right, we shoud consider creating easy to use code an protected could be misunderstoud to beginners.

I opened a second pull request #2 with some fixes to your di class and the proposed type hint detection alongside to your aliases. Instead of using a third party lib I would suggest improving the existing code and making it more transparent for new devs.