What is the purpose of the Model folder of the Inphinit framework?

9

In the Inphinit micro-framework there is the Model folder that is inside the application , and that's where classes , but I'm very confused about these classes.

View a class inside the Model folder:

<?php
namespace Model;

class User extends \Inphinit\Experimental\Model
{
}

Questions

  • I would like to know what is the purpose of the Model folder?
  • What is the class for the Model folder and how important is it do these classes have in relation to how my Web application works?
  • If you can explain me with practical examples it will be easier for me to understand .

        
    asked by anonymous 15.03.2017 / 02:23

    2 answers

    2

    jHertel has already given a brief introduction to what MVC is, some questions that can help you about this specifically:

    From my summary point of view, MVC does not have a specific standard, in fact in many ways you can make use of it and achieve the same result, being strict or not, inphinit is not strict, truth is very "free", with the exception of Controllers which are almost always required (although it supports Closures / a>).

    So the MVC is a way to organize and not a technology, from my point of view, the most common MVC represented is this:

    Inheritfollowsmanythingssimilartootherknownframeworks,withthefolderandnamespaceforControllerandModel(Viewhasnonamespace),thisclassyoupostedwasoneoftheexperimentalexamplesyouweredoing:

    <?phpnamespaceModel;classUserextends\Inphinit\Experimental\Model{}

    AtthemomentIremovedtheclass\Inphinit\Experimental\Model,notbecauseitiswrong,butbecauseitstilldoesnotachievewhatIexpect,frommypointofview,Modelshavenothingtodowiththedatabase,theyonlyusethedatacontainedinthem,ThepurposeoftheModelistodefinethe"business rules", thus making use of any type of information, having the ability to obtain them, update and delete, but all this having rules.

    However, I believe that a Model, wherever it is, should never manipulate things directly, type send data to ouput, or send response, it should only send the response (if any) to the controller and the controller should take care of it. rest (of course I rely on this with the experience I had with totally different tools, as MVC said is not always the same in two different places or frameworks).

    In most frameworks I notice the Model is used merely as a tool for connecting to the bank, and some rules end up falling within Controller .

    When I designed inphinit it had 5 goals:

  • Support PHP 5.3
  • Spend as little memory as possible
  • Be as fast as possible without there being many cycles within the kernel.
  • Being as simple as possible for learning
  • Support thirdparty libraries that are installed via composer
  • With this last goal we have reached namespace Model; and the system/application/Model/ folder, the framework does not have anything like migration , connection and sqlbuilder , but this does not mean that you can not install third-party stuff, there are frameworks that I've even used with it like:

    In other words, the focus of the folder and namespace Model is the same as that of most frameworks, however you can use the ORM you want or as desired >

      

    As soon as possible irie add a step-by-step one or more frameworks to work with the namespace Model .

        
    17.03.2017 / 19:58
    8
      

    I'd like to know what the purpose of the Model folder is?

    Usually in web applications we use a form of project organization called MVC. ( M odel- V iew- C ontroller)

    • Model Classes related to database and business rules

    • View Templates with HTML / Template language to view the contents of your application.

    • Controller Classes that control the application. It's like a glue between models and views. It is usually in the controllers that the application checks whether it is a GET, POST, etc. and makes the decisions about which View to show, how to process the data, etc.

      

    What is the class for the Model folder

    In this organization model the classes that correspond to the business rules and connection to the database are usually in the Model folder.

    It is a form of organization and you can choose to follow it or not.

      

    And how important are these classes in relation to how my Web application works?

    The importance of the templates is to make the business and database rules of the rest of the application clearer and separate.

    Currently MVC is heavily used in frameworks, although I never see an exactly same or standardized structure. This serves more as a guideline to keep the organization, but you are always free to change and use as needed.

        
    15.03.2017 / 13:13