BACKGROUND / IDEA
I am currently working on a small framework just to improve my php-knowledge. This framework should be very simple (minimizing overhead) and flexible in terms of later expansion.
DIFFERENT MEANINGS
As a result of reading more advanced tutorials, notes of serious php-developers, different class structures (singletons, Singletons, dependency injection, JIT, ...), oop, mvc, routing, caching... and a lot more I find it very difficult to filter "the proper way" (if there is one) as it seems to me that everyone says something different.
Many people praise there opinon as "the best" and say that everything appart from that is evil. In my oppinion there is not a right or false. There are just several ways to achieve one's goal.
WHAT I DID SO FAR
I know that this is very basic and I did not that much so far but I want to create a solid platform first.
QUESTIONS
Before I want to go any further in my project I'd love to hear your opinion on the things listed below.
WHAT I DON'T WANT TO HEAR
Many thanks in prior for every response I get.
I am currently working on a small framework just to improve my php-knowledge. This framework should be very simple (minimizing overhead) and flexible in terms of later expansion.
Go for it.
As a result of reading more advanced tutorials, notes of serious php-developers, different class structures (singletons, Singletons, dependency injection, JIT, ...), oop, mvc, routing, caching... and a lot more I find it very difficult to filter "the proper way" (if there is one) as it seems to me that everyone says something different.
That's because some people don't have an understanding why something should be solved in a certain way or why something is terrible practice, but they see something on some framework and they think it's the best thing since sliced bread.
Although opinions may differ, you cannot argue with clean code and proper OOP if that is what you are after. In proper OOP singletons and static
s have no place. Also what most people call MVC is actually some wrong view on the pattern (mostly because again they have seen some framework do it some way). Which is not always bad, but it is not MVC.
Many people praise there opinon as "the best" and say that everything appart from that is evil. In my oppinion there is not a right or false. There are just several ways to achieve one's goal.
Not everything that isn't the best is terrible in my opinion. But some stuff is just bad practice. And some pattern are defined in a way to make your applications easier to maintain, debug and test. If you are going to implement some other pattern that's all fine with me, but you will loose the benefits of some other pattern.
Generally speaking the first rule of thumb I use when doing OOP programming is following the SOLID principles.
static classes: htmlManager, fileHandler, databaseManager, ...
These have no place in proper OOP. Amongst others because the will tightly coupling the classes. Which make maintainability, readability and testability a pain.
singletons: none
Good, because they are just a fancy global
.
How do you organise/structure small or even bigger projects?
Separation of concerns in both code as structure. One of the pattern can help you with that: MVC, MVP, [MVVM](Model View ViewModel). For me personally I like the MVC pattern the most because it has some nice benefits against other patterns.
What are your experiences concerning simplicity, logic, performance, readability, expandability and reusability of code?
Readability and testablity are the most important. Right after that SOLID (which is also handled by the first point (overlap))
Forget about a framework or php Don't do this, don't do that without naming the reason why
As I stated before: Just go for it. Do it and screw it up! Best way to learn is actually doing it and making terrible mistakes. I think the framework I made 1 year ago (although imho still better than 90% of what is out there) is a proper piece of crap ™.
How do you organise/structure small or even bigger projects?
Many PHP frameworks use the MVC structure.
What are your experiences concerning simplicity, logic, performance, readability, expandability and reusability of code?
Beside strict following of MVC I would suggest following principles like KISS and DRY. I would not consider performance as a high priority topic. You can get yourself familiar with caching strategies and good algorithms later (general topics, not PHP).
Is there really a "proper way" of coding or it this just interpretation?
There are some things that could be considered as best practice, you will find many hints on popular frameworks like Zend or symfony.
Is there anything one should not use because it is already obsolete?
You'll have to find out for yourself. You could skip writing a database handling and use ORM libraries like doctrine or propel. You could choose a special template engine for your view-representation like twig or smarty.
Don't do this, don't do that without naming the reason why
I think all long-time PHP programmers started their own framework at least once, there is no argument against it, especially not if you want to improve your knowledge.