Laravel5 why put the model directly in the app directory?
Source: Internet
Author: User
KeywordsLaravel5phplaravel Software Design
Title, it certainly has his purpose, but why?
In addition, the model is the database, if not, what is he?
Laravel Novice.
Reply content:
Title, it certainly has his purpose, but why? In addition, the model is the database, if not, what is he? Laravel Novice.
Laravel I've been using it for a while. It feels really good. MVC weakens a lot in it. This concept is not even mentioned in the official documentation. The file that it puts in the app directory I feel like I should be an entity In general, an entity corresponds to a table And model This is a very broad concept I understand that it should include business logic, form validation, data writing, etc. This is supposed to be a complicated thing. If we force all these things into the entity, will cause the entity to be overweight. But where does this file go? I feel as if you feel justified You can do that in the app directory. These are just my personal thoughts. If you have any errors, please include
The model is the interface that gets the data. Most frameworks use Orm, which is object-relational mapping. Maps a table in a database into an object in a programming language, that is, a model. I don't know why I put it under the app, and I think it's better to put it in a folder.
I think 1-you think too much. 2-A little blind worship
First, whether it's a tutorial or a document is usually just a way of demonstrating a usage, rather than requiring the user to copy the document. Second, sometimes the code is non-developer-meaningful. Anyway, I still go to see L5 things, just speculate, may L5 inside optimization restful, after all, now this usage is more and more common, so in order to promote their main push new features just like this demo. For restful, if L5 integrates restful routing, tokens, or other security mechanisms, then the front-end uses a framework such as angular, which is sufficient. Finally, a lot of things don't need to be studied. Socket function source code is often accompanied by a chat room demo, we use these source code to build a socket application must also implement a chat room?
It's also possible to play like this.
I understand the model as an abstraction of the records in that table, and the instance of user represents every record in the users table
This question, Laravel's author Taylor, has said that because each person's understanding of the model is different, there are various opinions about the location of the placement, so simply put it in the root directory, and give you the right to choose;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.