PHP Laravel框架入门心得 | How to study PHP Laravel Framework
PHP有不少开发框架,其中比较出名的有Symfony和Laravel。
我说说我最近入门Laravel的感受和学习方法吧。
1。第一个感受是Laravel的社区讨论和学习资源真的是太棒了,中文化也做得很好。最令人印象深刻的是下面这个学习资源
https://laracasts.com/
里面很多Laravel的视频教程,我学的是这个
https://laracasts.com/series/laravel-from-scratch-2017
不仅能学到PHP Laravel的知识,而且能学到他的编程风格,好的编程习惯等等。
另外一个是laravel china的中文社区
https://laravel-china.org/
我看到不少好资料,其中
http://laravel-china.github.io/php-the-right-way/
这个很全面的介绍了PHP的入门和编程规范,特别好。
2。Laravel本身也是一种MVC框架,model,view,controller。它的内在流程是这样,一个HTTP REQUEST从客户段浏览器进来之后,由laravel的ROUTE来接收,ROUTE可以绑定一个Controller的方法,由这个方法来处理进来的这个HTTP REQUEST。在Controller的方法中,可以引进Model,就是核心的业务实现了,Model是通过Migration跟DB连接的,可以通过对Model对象的操作,实现对数据库的操作。最后Model对象操作完了之后,把结果传给View,View会绑定一个PHP,实现前端页面的显示。
这是Laravel最基本的结构,在此基础上可以实现更多复杂的功能。
----------------------------------------------------------------------------------------------------------------------------------------------------
English Version
----------------------------------------------------------------------------------------------------------------------------------------------------------
There are many PHP frameworks, representative ones are Symfony and Laravel.
As I learned Laravel Recently, I'd like to share my experience.
1. The first impression of Laravel is that the learning community is excellent, in which it provides tremendous resources to help people study and master the framework. I like to watch video tutorial to study new knowledge, so laracasts is my favorite.
https://laracasts.com/
There are many video tutorials, what I followed is as below
https://laracasts.com/series/laravel-from-scratch-2017
Not only I can learn PHP Laravel gramar, but only I can follow the video teacher's good programming style and preference and so on.
2. Secondly, let me briefly introduce Laravel framework structure. Laravel framework follows MVC desagn pattern, Model, View, Controller. It works like below
One HTTP Request is send by client browser and it be handled by Laravel Route. Route will bind a method function of Controller, in which the method will take over the HTTP Request, meanwhile Model instances are declared at the method. The Model is connected with DB through Migration object. We can manipulate the DB by directly alter Model instance. The core business logic is implementd at controller method. Finally the output of the method will pass to View, which is the frontend presentation layer.