Introduction 介绍

Where does this class belong? This question is extremely common when building applications on a framework. Many developers ask this question because they have been told that "Model" means "Database". So, developers have their controllers that interact with HTTP, models which do something with the database, and views which contain their HTML. But, what about classes that send e-mail? What about classes that validate data? What about classes that call an API to gather information? In this chapter, we'll cover good application structure in the Laravel framework and break down some of the common mental roadblocks that hold developers back from good design.

这个类要写到哪儿?这是一个在用框架写应用程序时十分常见的问题。大量的开发人员都有这个疑问。他们被灌输 “Model” 就是 “Database” ,在控制器里面处理 HTTP 请求,在模型里操作数据库,视图里包含了要显示的 HTML 。不过,发送电子邮件的类要写到哪儿?数据验证的类要写到哪儿?调用外部 API 的类要写到哪儿?在这一章节,我们将学习如何写结构优美的 Laravel 应用,打破长久以来掣肘开发人员的普遍思维惯性这个拦路虎,最终做出好的设计。

results matching ""

    No results matching ""