Why do lightweight frameworks like slim not strictly differentiate between model layers?
認(rèn)證0級(jí)講師
In fact, dividing levels is a logical problem. Many novice users use frameworks from the beginning and are spoiled by frameworks. Frameworks can do almost everything. All they have learned is to write code under a certain framework. , and out of the frame, only confusion remains.
Even if a heavy framework like domestic Thinkphp
provides the Model
layer, there are still very few people using it. Why? Because using the Model
layer requires you to divide the logic yourself and write code yourself, which is painful for them, so almost all the people I have seen operate the database in the Controller
Directly M('table')->insert($data)
and so on. The utilization rate of the Model
layer is extremely low. Thinkphp
這樣的重型框架,他提供了Model
層,用的人仍然很少,為什么?因?yàn)橛?code>Model層還需要自己劃分邏輯,仍少不了自己寫(xiě)代碼,這對(duì)他們來(lái)說(shuō)是痛苦的,所以我見(jiàn)過(guò)的幾乎所有的人操作數(shù)據(jù)庫(kù)都是在Controller
里直接M('table')->insert($data)
等。Model
層的利用率極低。
而對(duì)于非小白用戶,Model層無(wú)法就是個(gè)封裝了某個(gè)表的數(shù)據(jù)庫(kù)操作類(lèi)而已,隨手就創(chuàng)建了,何須框架來(lái)多此一舉,浪費(fèi)性能?
只要心中就有mvc
,一切都有層次。
而且,隨著composer
For non-novice users, the Model layer cannot be just a database operation class that encapsulates a certain table and is created casually. Why do we need a framework to do this and waste performance?
mvc
in your heart, everything has levels. ??Moreover, with the emergence of composer
, PHP development has gradually become modularized, instead of the previous framework. Now more and more people write code that uses modules directly instead of the entire framework. ??