search
HomeBackend DevelopmentPHP Tutorial新人刚接触 PHP,哪种框架比较容易上手?

接触php不久,但想了解下PHP框架,熟悉下MVC的思想,之前都没接触过这类框架,想问下大家有什么好的框架可以推荐,考虑的出发点又是什么。特别是对于新人~

回复内容:

我习惯看英文的Framework,在StackOverflow和Quora也看了许多讨论,其实框架这个东西,很大程度上是习惯的问题。还有一点,就是要选一些经常维护的框架。如果学了一些冷门的框架,结果人家不维护了,那其实很浪费。
总结一些我用过的几个框架:
  1. CodeIgniter:我曾经用的是1.7版本,代码效率一般,因为是要兼容PHP 4的缘故。2.0之后就放弃了PHP 4,代码更干净了。官方文档非常详细,社区也很大,用的人很多。缺点是没有一套很好的ORM库,默认的Model基于ActiveRecord,但是其实就是一个SQL的延伸。
  2. Zend:所谓的官方PHP框架,架构很松散,可以按需要取用。一开始不是很好学习,但是如果真正懂了的话效率也很高。由于有Zend在背后,所以不会担心不维护的问题。缺点是文档虽然看起来很多,但是并不容易看懂。
  3. Symfony:应该是法国人的老牌Framework,非常庞大,适合企业级别的项目。许多配置用YAML,而且对于环境的要求很麻烦,我简单看了看就放弃了。
  4. Yii:应该是华人开发的,以前和朋友开发的时候用过,Performance很不错,但是里面的Coding Style不是很喜欢,文档也不错。
  5. Kohana:曾经是基于CI的,但是后来重写了代码,但是继承了CI的哲学。HMVC架构并不是很容易学,但是代码非常干净,高效。自带的ORM也不错,缺点是文档不全面。
  6. 编辑1:差点忘了CakePHP:这是我接触的第一个框架,也是最像Ruby on Rails的框架,Bake script可以自动生成许多东西,但是我反而不是很喜欢自动生成。运行比较慢,大概是overhead太多的缘故。支持PHP 4,但是后来几个核心成员新建了一个PHP 5.3的框架叫Lithium (lithify.me/),原生支持MongoDB,我只看了看文档,还没有用。

上面是常见的框架,也都是全面的框架。下面有一些冷门的,轻量级的:
  1. Slim Framework:我个人最喜欢的轻量级框架,基于RESTful route组织的,压缩包才80KB。继承了Sinatra和Web.py的哲学,我跟作者以前讨论过,他在1.5从Singleton换到了Instance,我反而觉得没必要,我很喜欢1.3版本。这不能算是一个full stack MVC framework,也没有强制要求OO。
  2. LightVC:这个更轻量(压缩包24K),只提供VC,不提供Model,做着同时谢了一个ORM叫CoughPHP,配合起来不错。
  3. Flourish Lib:这不应该是一个框架,而是一些Library的集合,里面许多Lib很好用。

最后再推荐一个ORM,一般流行的是Doctrine和Propel,我自己最爱的是RedBean。现在开发都是用Slim来做Route,从Flourish拷贝一些代码,再用RedBean来做ORM,虽然看起来很绕弯,到时我自己习惯了,驾轻就熟也就OK。 强烈不建议新手上手框架!
另外,yii和CI有什么关系?? 我比较推荐CI-codeignighter.

说下几个理由:
  1. 成熟的开发社区,有一帮人和你一起在学这个框架,你不懂的时候可以问,在国内有中文社区(codeigniter.org.cn/)
  2. 相对容易的学习曲线,对比zendframk,它的语法还是相对简单很多,而且有一些配套的书籍可以参考,虽然比较旧了,但还是有参考价值。
  3. 详细的帮助文档,ci的官方博客上有UserGuide,可以帮你迅速了解相关的语法和功能,非常的详细,而且ci框架本身也做了非常多的注释。
总结:可以说,ci对于初学者来说,是一个非常不错的框架,上手容易。

附注:参考书籍列表
CodeIgniter for Rapid PHP Application Development
book.douban.com/subject 如果刚接触PHP的话,我建议不要先碰框架。框架里面有很多提炼的东西在里面,容易让人知其然而不知其所以然,不利于基本功的训练。

MVC是一种编程的思想,和框架关系不大,你可以很熟悉MVC而不熟悉框架,你也可以很熟悉框架而不熟悉MVC PHP中没有像ASP.NET那样的MVC架构,像CI都是通过router的方式实现MVC,个人建议还是先从基础的学起,深入学习后再使用框架。当你再使用CI, Zend 等PHP框架时,你会发现其实本质上都是差不多的,知其然,更知其所以然。 国内的话,英文不是很好的推荐thinkphp或者CI文档都比较全。
英文好点的推荐yii 建议还是选学好PHP基本先吧,再考虑一下CI、SpeedPHP、ThinkPHP,后面两个中文文档比较齐全。 PHP新人,建议先掌握PHP,以后再学习及考虑框架。
PHP框架,看自己喜爱吧。 我的团队在使用CI

ThinkPHP,CI都很不错,相关中文学习文档也多。
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
PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

How does PHP handle object cloning (clone keyword) and the __clone magic method?How does PHP handle object cloning (clone keyword) and the __clone magic method?Apr 17, 2025 am 12:24 AM

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP vs. Python: Use Cases and ApplicationsPHP vs. Python: Use Cases and ApplicationsApr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.