search
HomeBackend DevelopmentPHP Tutorialphp框架 - 用php做一个网站或者app,框架真的很重要吗?

自己想做一个sns网站,选择php框架中。每次在网上都能看到很多争论,鄙视,说哪个框架好或者不好。我想知道的是,框架真的重要吗?

回复内容:

自己想做一个sns网站,选择php框架中。每次在网上都能看到很多争论,鄙视,说哪个框架好或者不好。我想知道的是,框架真的重要吗?

不重要。其实不管你做什么项目选错了框架最大的影响也就是开发速度,不影响代码质量、后期维护、业务逻辑这些最核心的东西。比如你需要RESTful,但是选了一个不支持RESTful的框架,那就要自己处理路由问题了,其它没影响。

无规矩不成方圆,框架本质上就是规矩的集合。框架重要,但是不是说哪一个框架重要。
找到一个适合你口味的、或者你自己写一个你认为最好的, 都可以。 相信你会因此受益!

框架是别人经验的积累。
“别人”,也就是这个经验是别人的,未必全部适合你;“经验的积累”是指里面都很多优秀的东西,可以直接拿来用。

所以,无论是是否愿意使用框架,你都应该好好研究研究,比较比较,最后挑选一个最适合自己的,哪怕你最后哪个都不用,也可以学习不少东西。

其实,写过几年程序的通常都有对于某些问题(比如输入过滤、图片上传、验证码等)的常规解决方案,这就是你自己的“框架”。

等你用了几个再说吧,其实如果没写多少代码就考虑这种问题就是浪费时间,就像我当初考虑该学哪个语言一样。

人而异 对于不用框架能出活的人来说不重要,对于离了框架干瞪眼的来说很重要 ,对于不会3,4个框架之外拿不出东西给跟人装逼的来说尤其重要

其实并没有重不重要这一说的。主要是看你是想要开发效率还是运行效率。
框架会牺牲你的运行效率,但是会大大提升开发效率。举个例子。
我现在要写个一路由 www.xxx.com/api
以laravel为例

<code>Route::get('api',function(){
    echo 'hello';
})</code>

这样我们就完成了一个访问www.xxx.com/api,输出hello字符的页面了。
那么没有框架尼?额,我觉得这个页面应该装不下代码了。

这里我并没有说框架有多好,如今的银弹法则依然存在,我们无法让开发效率和运行效率同时提升。
所以必须在开发效率和运行效率选择。框架因此而生。

至于框架的好与坏完全取决于个人的喜好,比如有些人喜欢thinkphp的自动控制器路由,有人喜欢laravel的手动可控路由,于是就有人开始了……

框架的好和坏毕竟不是那么容易评定的,毕竟那么多使用者尼。

所以选择框架完全看需求,你老板说让你1小时不用框架做一个blog,如果不是大触,我觉得真的会崩溃掉。
如果选择框架,那估计也是10分钟的事情。

框架的主要作用是帮你省去大部分无聊的代码。

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 Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot 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.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

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.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment