为什么大多数互联网公司自己写 PHP 框架?
是公司自己写,还是使用开源的框架。为什么做这样的选择,是基于什么考虑?本人看过很多的公司内部框架,说实话,真没开源的写的好,无论是文档还是易用性。好多人的想法是,如果让人知道公司开发的框架是用的开源框架,会被人鄙视- -。大家是否也有这样的考虑?
回复内容:
因为要有个性 事实是,他们技术总监想写个框架练练手,所以就忽悠ceo,说怎么怎么需要。基本都是这样的原因。普通mvc框架完全没有自己写的必要,像鸟哥的yaf,phalcon这种才是需求产生的。 看过用过一些开源框架,像Yii、CakePHP、CodeIgnitor, 同时也为某个大型公司开发维护过内部的框架,简单说说我的观点:
1. 开源框架好是好,但做 PHP 开发的大多围绕项目需求走,没有需要也没有动力去学一个开源的框架,即便要使用,选择哪个框架也是个很困难的事。通常就算用了开源的框架,也只是用了其中一部分,大多没有理解框架设计的原则,一旦需要对框架做扩展时就胡乱来了;
2. 开源框架做的都是通用的需求,而企业内部往往有特殊的需求,自己做框架能够更切合实际的需求,出现 bug 改正也会比较及时。如果使用开源框架,往往要在深入理解内部原理上下不小的功夫,显然没有自己写的代码熟悉;
3. 性能偏见,某些人认为大部分框架中绕来绕去的方法调用、为解耦引入的多次层架构,对性能有影响,因而认为自己写的“简单”代码有更高的性能。这类人往往鄙视设计模式一类的东西,出来的代码当然要更混乱。 简单说,因为PHP这门语言太烂了,以至于很难写出足够好的框架。这一方面导致许多人认为自己能写得更好。另一方面,要写到足够好的,最终就非常不象PHP。所以或者觉得要么不如直接用其他语言(写的框架),或者认为这丫已然不是PHP了。
补充:
关于PHP的烂:框架本身是要提供强约束,比如分层隔离,禁止业务层访问表现层,但PHP的大量函数都在全局命名空间下,你无法禁止对这些函数的访问。归根到底,PHP本来就是设计为对于Web层的抽象。既然要写框架,则隐含前提是认为PHP自身的抽象不够好。重造一层抽象之后,整个就和传统PHP背道而驰了。从某种程度上说,PHP的哲学是反框架的。
- 公司有没有自己的框架其实要看公司自身的实力,PHP更多的是一些创业型的公司使用,从成本上来说不适合自己独立开发框架,因为一个良好的框架,业务,安全,性能等等都需要很长时间来考验。
- 当然有些小公司也会自己写框架,原因很简单自己的业务简单也不需要那么复杂的框架,借鉴一下MVC开发思想,写一个简单的框架也没有那么复杂,另外网站的性能也不是PHP这个框架所决定的,linux和websever的优化和配置以及对数据库的优化和使用都是很重要的因素。
- 另外关于说PHP不适合大型网站构架纯粹胡扯,不是说他不适合,而是早期的PHP不是很成熟(相对于java和c来说),而且早期的web程序员主要也是以java语言为主,后来虽然PHP技术成熟后,但他们(早期java)占据了公司的领导岗位,对以后的项目会本能的采用自己熟悉的语言和知识。PHP的劣势是:1:没有占据早期开发优势(人们一般有先入为主的思想),导致现在PHP不能成为大网站的主导语言,2:属于草根开源语言,在面临bug问题上面,只能等待或者自己做扩展,不像甲骨文可以付费解决问题
- 就性能而言,PHP适合快速迭代的开发模式,例如新浪微博就是采用PHP,一个良好的LAMP架构支持百万级的业务量还是相当easy的
如果项目时间赶,而且公司又没有成熟的开发框架,那么选择开源框架就可以缩短开发周期。
如果时间允许,开发团队人员多一些,那么还是公司独立开发一套好一些。在安全性上也会比较有保证。 php比较简单且速度快,开源又免费,lamp(linux操作系统+apacheWEB服务器+mysql数据库+php)架构成熟稳定,所以很多网站采用。 大多数都是自己写的或是在开源框架上进行大规模的二次封装
原因是各公司的业务需求差别很大
嗯嗯,就是这样 看公司的项目,需要快速反应的,例如给客户做网站,用开源的会有比较多,如果是自己运营的项目,例如自有网站、或者开发自有的软件,那还是自己写比较靠谱,甚至互相结合,交错着用。。。 每个公司都想有一套属于自己的系统

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
