Within the past year, I am a beginner at web development. I am currently designing a sort of online portfolio to host my projects and such, but before I get thousands of lines of code into it, I would like to know what kinds of practices I should use to get the most out of PHP, Javascript, and OOP.
For example, more of the PHP tutorials have the PHP interleaved heavily with the HTML, which I heard is really bad design.
Obviously there are multiple ways to go about this, and I don’t want to start any debates or arguments, but I would like to know exactly what is out there. Like, for example, I recall some design patterns creating Classes for the pages themselves.
I hope what I’m asking about is clear above! And this will be good help for other folks like me beginning web programming in the future.
I am aware that there are many frameworks as well. But for the sake of getting practice and learning about programming, I would like to do a lot on my own as well.
Beyond MVC, there are two branches (if I may call it that way) from it, that is, HMVC (hierarchic model view controller) and MVVM (model view viewmodel). You may get both of them (HMVC and MVVM) using Kohana framework. The view models are quite “new”, but the principle is always to designate each ‘letter’ to do something. For example, the controller deal with your requests, parameters sent by the browser and outputting the proper information. The model deals with data, may it be in the database or just a file representing some “raw” data that should be displayed after, in your “view”.
Usually, in the MVC pattern, you’ll load your models from your controller and pass the necessary information to the view. In the MVVM approach, your views will be loading the necessary models to that view, without the need of the controller “controlling” the actions.
The “H” part means you can actively extend the whole framework, from SYSTEM to MODULES to APPLICATION, as many class extensions you may need, and as many versions of these extensions you may need as well. For example, by extending the
Controller_Templateclass, you may createclass BaseTemplate extends Controller_Templatethen after, you may inherit the basic functions fromBaseTemplateonclass FrontEnd extends BaseTemplateandclass BackEnd extends BaseTemplate, where theBackEndclass will deal with authorization to allow access for certain parts of the backend, etc. And Kohana 3.x plays really well with IDEs, that should make it easier to get the grip and start coding with code completion and quick documentionCertainly, frameworks got many tools to help you finish your work faster, but the main point is to help you keep your code organized.