您的位置 首页 php

PHP 几种常用框架的区别

PHP 几种常用框架的区别

工作中使用的是TP框架,在工作之余接触了一下Yii框架和Laravel框架,为了更好的了解几种框架,此处总结一下几种框架各自的优势及缺点。

一、CI框架

CI框架是一个简单快速的PHP MVC轻量级框架,它执行效率高,快速简洁,代码量少,适合中小型项目开发,也可以做大型项目,但扩展能力不是很好。

优势:框架比较简单,适合入门开发,易学,上手快,静态化很容易,文档比较详细。

缺点:由于框架较小,所以功能不完全,比如使用mongoDB就要自己实现接口,对数据库的操作不够安全(写入操作)。对大型项目支持不好。

开发工作流程:

1、index.php作为前端控制器,初始化运行CodeIgniter所需要的基本资源。

2、Router检查HTTP请求,以确定谁来处理请求。

3、如果缓存(Cache)文件存在,它将绕过通常的系统执行顺序,被直接发送给浏览器。

4、安全(Security)。应用程序控制器(ApplicationController)装载之前,HTTP请求和任何用户提交的数据将被过滤。

5、控制器(Controller)装载模型、核心库、插件、辅助函数,以及任何处理特定请求所需的其它资源。

6、最终视图(View)渲染发送到Web浏览器中的内容。如果开启缓存(Caching),视图首先被缓存,所以将可用于以后的请求。

CI的url模式:

Ci支持的url模式默认为pathinfo形式,也就是使用/隔开。其中//localhost/citest/index.php/ 是固定的,表示的就是入口文件

例如://localhost/citest/index.php/hello/index

二、ThinkPHP框架

TP框架是一共快速兼容简单的轻量级国产PHP开发框架,使用面向对象的结构和MVC模式进行开发。它可以支持Windows、Linux等服务器,并且支持MySql、Sqlite等多种数据库和PDO扩展。其自身包含底层架构、兼容处理、基类库、数据库访问层、模版引擎、缓存机制、插件机制、角色认证、表单处理等常用的组件,并且对于跨版本、跨平台和跨数据库移植都比较方便。适合中小型项目开发。

优势:简单易用(Model,Controller,View负责各自的工作),它拥有支持XML标签库技术的编译型模版引擎,支持两种模版标签,动态编译,缓存技术。还支持自定义标签库,具有独特的数据验证和自动填充,MD5数据加密等功能。部署简单只需要一个入口文件,上手快。

缺点:模版比较固定,导致思想容易固化。

TP框架中提供的4种路由形式,其中rewrite路由方式需要另外修改配置才可使用,配置方法见

1、get路由形式;

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

2、pathinfo路由形式【默认路由形式】:

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

​ 3、 rewrite路由形式;

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

4、 兼容路由形式:

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

三、Laravel框架

Laravel是一套简洁,优雅的PHP WEB开发框架。集合了PHP比较新的特性,以及各种的设计模式,是一个适合学习的框架,但要求PHP基础扎实熟练。适合大中型项目的开发。

优势:

1、支持Composer

2、框架结构比较清晰,注重代码的模块化(抽象了中间件,任务,服务等)和可扩展性,路由系统快速高效

3、支持处理跨站请求伪造,在进行form表单post提交时,必须传入{{ csrf_field() }}

4、Laravel 的社区很强大,具有丰富的扩展包及工具

5、具有缓存、身份验证、任务自动化、hash加密、事务等功能

6、独特的 .env环境文件,方便了系统的配置和不同平台的开发

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

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
 

四、Yii 框架

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

优势:

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

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

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

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

5、支持composer包管理工具

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

文章来源:智云一二三科技

文章标题:PHP 几种常用框架的区别

文章地址:https://www.zhihuclub.com/77376.shtml

关于作者: 智云科技

热门文章

评论已关闭

37条评论

  1. For information contact Kern Wind Energy Association 661 831-1038 or the Chamber office at 661 822-4180 or email

  2. Either animal studies show no risk but human studies not available or animal studies showed minor risks and human studies done and showed no risk

  3. I m only 10 DPO today but I m pretty positive this is a viable pregnancy. Chemically it is a derivative of triphenylethelene and a mixture of zuclomifene Z -clomifene and enclomifene E -clomifene which are geometric isomers which are the reason clomiphene citrate has both estrogenic and antiestrogenic properties.

  4. For the 150 couples that actually started, compliance with diet was assessed through mineral analyses of blood and timing of intercourse relative to ovulation was determined by ovulation tests.

  5. I dont know i wish i just had a ton of money to do a ton of blood tests at different times as an expeiriment This difference ranges from 11

  6. CoQ10 used in the methods exemplified herein have the following characteristics residual solvents meet USP 467 requirement; water content is less than 0

  7. The first phase goes immediately after the steroid cycle is complete, and it should last anywhere from four to six weeks A separate carcinogenicity study was conducted in rats at the doses of 30, 100, and 315 mg kg day exemestane gavage for 92 weeks in males and 2 years in females

  8. Critically, all informative individual n 5 and pooled n 1 CTC samples harbored the same heterozygous PIK3CA p

  9. com If you have concerns regarding CE, please contact service akhcme Serotype specific efficacy was also demonstrated against all four serotypes

  10. Using condoms during treatment and for at least 4 months following treatment to avoid conceiving a child Taking no other medications, including over the counter and herbal preparations, without discussing first with one s healthcare provider Notifying the healthcare provider immediately, day or night, if any of the following occur Fever of 100 In addition, he says several studies show some drugs that regulate genes, such as the breast cancer drug tamoxifen, also appear to knock down COVID 19 risk

  11. Recent study shows that NR5A2 increases breast cancer cell growth by directly binding to the promoter of ER О± gene and inducing its expression

  12. Engineers and scientists must rise to the challenge of developing this next generation of neurotechnological devices

  13. b Tumor growth kinetics in mice grafted with GО±q Q209L transformed Ric 8A Flox Flox; Rosa CreER melanocyte cell lines with or without stable RIC 8A Tg expression, followed by intraperitoneal i

  14. After 2 weeks on their respective diets, the animals were weighed and a urine samples were obtained

  15. We applied the computational approach on four BC subtypes with different diagnostic classification and prognosis 9 luminal A tumors expressing hormone receptors, with a favorable prognosis; luminal B tumors expressing hormone receptors and high expression of proliferation genes with a good prognosis although with an increased risk of recurrence; basal like tumors lacking the expression of hormone receptors and HER2 but increased levels of cytokeratin myoepithelial CK 5 6 and CK 17, with shorter observed survival; and HER2 tumors overexpressing HER2, with the worse survival IC 50 values were calculated by nonlinear regression analysis using GraphPad prism software version 5

  16. After oral administration of lomustine, peak plasma levels of metabolites appear within 1 4 hours; central nervous system concentrations reach 30 40 of the activity present in the plasma Ever notice how when a driver gets dumped in a race how the horse gets afraid and takes off

  17. Enlist a friend with the same goal In women with ILC, there was a 62 reduction in the hazard of death with letrozole HR, 0

  18. In some embodiments, combining T CM enriched CD8 T cells and CD4 T cells further enhances efficacy

  19. Transdermal drug delivery has attracted much attention as an alternative to intravenous and oral methods of delivery

  20. Steroid Hormone, Bodybuilding, Muscle Gaining manufacturer supplier in China, offering Natural Muscle Building Steroids 99 Aim Among couples unable to conceive without any identifiable cause, 30 are defined as having unexplained infertility

  21. darunavir will increase the level or effect of efavirenz by affecting hepatic intestinal enzyme CYP3A4 metabolism

  22. All patients had a thrombotic occlusion of the iliac veins or the common femoral vein, with distal extension to the femoro popliteal deep veins in 32 67 cases, with proximal extension into the inferior vena cava in 2 4 cases and both proximal and distal extension in 6 13 cases Table 2011; 94 6 1471 1478

  23. Lipedema is a common SAT disease that was first described in 1940 at the Mayo clinic by Drs Patients with HR HER2 mBC who had progressed on 4 treatments for advanced disease were eligible

  24. However, because chemotherapy does not kill all of the adult worms, it is necessary to continue intermittent administration of antiparasitic drugs for many years, until the adult worms die of senescence Through the way of computer language, it defines how to do this action and viagra price online how to deal with this situation

  25. Do not talk The pavilion master of Yaodan Pavilion said to the eldest lady, then looked at Zhao Ling, and said coldly I just ask you, why did you force your way into my Yaodan Pavilion Why did you hurt make blood pressure go down fast my Yaodan Elder Pavilion Zhao Ling sneered and said to the can lasix lower blood pressure too much Pavilion Master of the Yaodan Pavilion, Your Yaodan Pavilion is rules are too far fetched Since nevi are composed of senescent melanocytes, it is possible that H2AFJ levels are increased during the senescence of melanocytes relative to normal melanocytes and metastatic melanoma, and a functional analysis of its role in melanocyte senescence might be illuminating

  26. Effect of sulfinpyrazone on homocysteine induced endothelial injury and arteriosclerosis in baboons The major signs of type 1 RTA and type 2 RTA are low levels of potassium and bicarbonate a waste product produced by your body in the blood

网站地图