Home >Backend Development >PHP Tutorial >What are the commonly used frameworks in PHP? Comparison of the differences between commonly used frameworks for PHP development

What are the commonly used frameworks in PHP? Comparison of the differences between commonly used frameworks for PHP development

不言
不言Original
2018-07-25 14:32:1215963browse

I use the thinkphp framework in my daily work. I came into contact with the Yii framework and the Laravel framework during my work. In order to better understand the several frameworks of PHP, I summarized them here. Let’s compare the differences between the four commonly used frameworks for PHP development.

1. PHP CI framework

The CI framework is a simple and fast PHP MVC lightweight framework. It has high execution efficiency, fast and concise , the amount of code is small, suitable for small and medium-sized project development, and can also be used for large-scale projects, but the scalability is not very good.

Recommended course : "CI Framework Video Tutorial"

  Advantages: The framework is relatively simple, suitable for entry-level development, and easy to learn , it’s quick to get started, easy to make static, and the documentation is relatively detailed.

 Disadvantages:Because the framework is small, the functions are incomplete. For example, if you use mongoDB, you need to implement the interface yourself, and the operation of the database is not safe enough (write operations). Poor support for large projects.

Development workflow:

1. index.php serves as the front-end controller to initialize the basic resources required to run CodeIgniter.

 2. Router checks the HTTP request to determine who will handle the request.

 3. If the cache file exists, it will bypass the usual system execution sequence and be sent directly to the browser.

 4. Security. HTTP requests and any user-submitted data will be filtered before loading the ApplicationController.

 5. The Controller loads models, core libraries, plug-ins, auxiliary functions, and any other resources needed to handle specific requests.

 6. The final view (View) renders the content sent to the web browser. If caching is turned on, the view is cached first so it will be available for future requests.

CI’s url mode:

The url mode supported by Ci defaults to the pathinfo format, which is separated by /. Among them, //localhost/citest/index.php/ is fixed and represents the entry file

. For example:

//localhost/citest/index.php/hello/index

. 2. ThinkPHP framework

TP framework is a lightweight domestic PHP development framework that is fast, compatible and simple. It is developed using object-oriented structure and MVC mode. It can support servers such as Windows and Linux, and supports multiple databases and PDO extensions such as MySql and Sqlite. It contains common components such as underlying architecture, compatibility processing, base class library, database access layer, template engine, caching mechanism, plug-in mechanism, role authentication, form processing, etc., and is more convenient for cross-version, cross-platform and cross-database transplantation. . Suitable for small and medium-sized project development.

     Recommended Courses: "Latest ThinkPHP 5.1 World Premiere Video Tutorial"

  Advantages: Simple and easy to use (Model, Controller and View are responsible for their respective work), it has a compiled template engine that supports XML tag library technology, supports two kinds of template tags, dynamic compilation, and caching technology. It also supports custom tag libraries, with unique data validation and auto-fill, MD5 data encryption and other functions. Deployment is simple and requires only one entry file, making it quick to get started.

  Disadvantages: The template is relatively fixed, which makes it easy for ideas to solidify.

There are 4 routing forms provided in the TP framework. Among them, the rewrite routing method requires additional modifications to the configuration before it can be used. For the configuration method, see https://www.cnblogs.com/lovele-/p/9256575.html

1. get routing form;

//网址/index.php?m=分组&c=控制器&a=方法(该形式书最底层的传输方式,不安全)。

2. pathinfo routing form [default routing form]: ​

 //网址/index.php/分组/控制器/方法

3. rewrite routing form;

 //网址/分组/控制器/方法

4 , Compatible routing forms:    

//网址/index.php?s=/分组/控制器/方法

 三、php Laravel framework

Laravel is a simple and elegant PHP WEB development framework. It integrates the relatively new features of PHP and various design patterns. It is a framework suitable for learning, but it requires a solid and proficient PHP foundation. Suitable for the development of large and medium-sized projects.

Recommended course : "Latest Laravel Mall Practical Video Tutorial"

Advantages:

 1 , Support Composer

 2. The framework structure is relatively clear, focusing on the modularization of the code (abstracting middleware, tasks, services, etc.) and scalability, and the routing system is fast and efficient

 3. Support To handle cross-site request forgery, when submitting a form post, you must pass in {{ csrf_field() }}

4. Laravel’s community is very strong and has a wealth of extension packages and tools

5. With functions such as caching, authentication, task automation, hash encryption, transactions, etc.

6. Unique .env environment file facilitates system configuration and development of different platforms

  缺点:基于组件式的框架,相对有点臃肿

  Laravel路由方法:laravel的路由功能很强大,包括

  1、基本路由Route::get('/',function(){   return'HelloWorld';});

  2、带参数路由Route::get('user/{id}', function($id){ return 'User '.$id;});

  3、路由过滤参数Route::get('user/{id}/{name}',function($id,$name){   //}) -> where(array('id'=> '[0-9]+', 'name' =>'[a-z]+'));

  4、子域名路由等等等等

  5、控制器路由,例如下面的一些样式

Route::resource('article','ArticleController'); //restful方式(具体包括get/post等)

  Route::controller('article','ArticleController'); //restful方式(具体包括get/post等)

  Route::get('user/login','UserController@login');//非restful方式 get

  Route::post('user/i','UserController@login');//非restful方式post

  四、php Yii 框架

  Yii Framework是一个基于组件、用于大规模web应用开发的高性能PHP开源框架,是目前最具效率的PHP框架之一。适合大型重量型web应用开发。

       推荐课程:《Yii开发大型商城项目视频教程

  优势:

  1、纯OOP开发,模型使用方便

  2、支持命令行工具开发,可以快速的创建一个web应用程序的代码

  3、具有高度的可重用性和可扩展性

  4、开发速度快,性能优异且功能丰富

  5、支持composer包管理工具

  缺点:model 层考虑较少,文档中中文文档较少。要求php技术精通水平,OOP编程也要很熟练

 相关推荐:

2019热门php开发框架排行

PHP四大主流框架的优缺点总结

PHP中常用的七大框架的优点与缺点

The above is the detailed content of What are the commonly used frameworks in PHP? Comparison of the differences between commonly used frameworks for PHP development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn