ホームページ php教程 php手册 霍然回首 ,PHP 竟然就是一个框架

霍然回首 ,PHP 竟然就是一个框架

Jun 06, 2016 pm 07:55 PM
php フレーム

(原题目:Last we checked, PHP is a framework. By Akash Mehta. June 8th, 2008 ) When it comes to web programming languages, PHP probably holds the record for copping criticism from the community at large. Comparisons with alternatives such a

(原题目:"Last we checked, PHP is a framework".  By Akash Mehta. June 8th, 2008 )



When it comes to web programming languages, PHP probably holds the record for copping criticism from the community at large. Comparisons with alternatives such as Ruby on Rails and Python/Django are common; defenders of PHP are quick to criticise the comparison of a language and a framework. But at the end of the day, developers work with Ruby on Rails, and with Python/Django, and with PHP. Just PHP. For most of the PHP applications out there, the language is just perfect, because PHP, to an extent, is the framework.


在谈到web编程语言时,PHP可能是受到社区最多批评的语言了。与其它同类语言如Ruby on Rails 和 Python/Django 作比较是经常的事了;PHP的护卫者们常常批评这些对语言和框架所进行的比较。但到了最后,使用Ruby on Rails的,和使用Python/Django的, 和使用PHP的开发者,都会使用PHP。对大多数现存的PHP应用,语言真是太好了,因为PHP,在一定程度上,就是一种框架。

PHP is designed for the web. You could plug vanilla Ruby or Python into a web server and get up and running pretty quickly. But, at least at a basic level, you’d want a framework to deal with common issues of web development. In PHP, you just get started. PHP and Apache work out request data, output handling and more, right out of the box. (PHP also masters deployment.) David Heinemeier Hanson, the creator of the Ruby on Rails framework, calls this the immediacy of PHP.


PHP就是为web而设计的。用户也可以把纯粹的Ruby和Python应用放在web服务器里并可以运行得很好。但是,至少在基础水平 上,用户还是希望使用框架来处理那些通常web开发会遇到的问题。使用PHP时,只要你动手就行了。PHP和Apache会在内部来处理需要的数据,输出 处理等问题。Ruby on Rails 框架的创造人David Heinemeier Hanson形容其为PHP的直接性。


Now, consider the “average” PHP frameworks. They help you handle request data, manage your output, control app flow - essentially, extending PHP’s inbuilt functionality. They are, therefore, PHP frameworks on the PHP framework. PHP provides a vast array (pardon the pun) of functionality out of the box. But when you want to do things your way, it gets out of the way, and this is really important when building anything beyond a simple database frontend.


现在,分析一下"普通的"PHP框架。框架可用于处理需要的数据,管理输出,控制应用流程 -- 基本上,就是扩展了PHP内建的函数功能。因此,也可以说,它们只是基于PHP框架上的PHP框架。PHP是提供了一大把可用函数,但如果你想按自己的方 式来行事,那还是不够的,但有时候,后者在你想做一些诸如比简单的提取数据放在网页上更复杂的事情时,还是挺重要的。

How many PHP applications in wide distribution are built on a third-party framework? MediaWiki? No framework here. Wordpress? Not here either. Drupal? You get the idea. Each of these applications have their own framework, inasfar that the developers built a structure for their code that suited what they were trying to create. These three, and the countless others, clearly did something right - MediaWiki even powers one of the world’s top 10 websites. And when building these “frameworks”, PHP helped them along the way.


有多少广泛分布的PHP应用是建立在第三方的公用框架上的呢?MediaWiki? 没用这些框架。Wordpress? 也没用这些框架。Drupal又如何? 看到这里,你应该明白了。这里的每个应用都有它们自己的框架,在这里开发者为他们的应用量身订造出合适的结构。这三个应用,联同其它无数的应用一样,做得 正确无误 -- MediaWiki网甚至成为了世界10个顶级网站之一。在建造这些"框架"时,PHP顺其自然地做了自己的事情。


Sure, Cake, Symfony, CI - they all help you build PHP applications. But unlike a Ruby framework or a Python framework, coding is perfectly tolerable without them. Of course, most developers tend to create their own framework as they go along - I call this PHP’s DIY framework mentality, where you build the last level in your stack, and by extension you know exactly what’s going on under the hood.


没错,Cake, Symfony, CI(Codelgniter) -- 都可以帮你开发PHP应用。但和使用Ruby框架或Python框架不一样的是,即使不用这些PHP框架,程序一样地好写。当然了,很多开发者都倾向于创 造自己的框架 -- 精神上我称之为PHP的自做框架,在那可以根据自己的需要来开发,并扩展自己最清楚的内部系统功能。


This comes back to the oft-cited “best tool for the job” argument - but by being a “half framework” of sorts, PHP simply helps you within a web context. I’m sure Rails is great for countless applications; Ruby syntax helps a little too. But beyond the basics, the language becomes increasingly irrelevant, and a framework will force you to build your app according to design decisions made by the original developers. On the other hand, PHP allows you to quickly put together your application the way you want, helping you with the web-based aspect, and without having to break the language/framework to achieve your goals. Essentially, PHP is the web layer without the framework baggage.


Twitter recently had some downtime that could be attributed to its use of Ruby on Rails. Now, there’s nothing wrong with Ruby, or Rails. But Twitter is a messaging system, RoR is an application framework. Could Rails be worked around to suit Twitter? Maybe. Could Twitter have avoided these problems if they’d used PHP? Probably. Twitter’s developers have noted they weren’t quite expecting the site to be so succesful. If they had built it in PHP, they would probably have encountered other (similar) problems earlier on, rewritten the entire app while it was still feasible, and built a powerful system that could scale just fine (likely with the messaging platform in C). Using PHP could have helped, not as a language with syntax and libraries as such, but as a web development platform that gives developers the freedom to architect their systems as they want. (They could also have tried Erlang.)


So the next time you’re on the lookout for a PHP framework to build your killer app on, consider using the best framework of them all: PHP. It will give you the freedom to achieve what you want, how you want, with results. A quick hack? Check the manual, it could be a one-liner. A massive distributed messaging platform? Full steam ahead, build it your way. For everything in between, there’s a multitude of options, but if you have the time, PHP is all the framework you need.

このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

CakePHP プロジェクトの構成 CakePHP プロジェクトの構成 Sep 10, 2024 pm 05:25 PM

この章では、CakePHP の環境変数、一般設定、データベース設定、電子メール設定について理解します。

Ubuntu および Debian 用の PHP 8.4 インストールおよびアップグレード ガイド Ubuntu および Debian 用の PHP 8.4 インストールおよびアップグレード ガイド Dec 24, 2024 pm 04:42 PM

PHP 8.4 では、いくつかの新機能、セキュリティの改善、パフォーマンスの改善が行われ、かなりの量の機能の非推奨と削除が行われています。 このガイドでは、Ubuntu、Debian、またはその派生版に PHP 8.4 をインストールする方法、または PHP 8.4 にアップグレードする方法について説明します。

CakePHP の日付と時刻 CakePHP の日付と時刻 Sep 10, 2024 pm 05:27 PM

Cakephp4 で日付と時刻を操作するには、利用可能な FrozenTime クラスを利用します。

CakePHP ファイルのアップロード CakePHP ファイルのアップロード Sep 10, 2024 pm 05:27 PM

ファイルのアップロードを行うには、フォーム ヘルパーを使用します。ここではファイルアップロードの例を示します。

CakePHP について話し合う CakePHP について話し合う Sep 10, 2024 pm 05:28 PM

CakePHP は、PHP 用のオープンソース フレームワークです。これは、アプリケーションの開発、展開、保守をより簡単にすることを目的としています。 CakePHP は、強力かつ理解しやすい MVC のようなアーキテクチャに基づいています。モデル、ビュー、コントローラー

CakePHP ルーティング CakePHP ルーティング Sep 10, 2024 pm 05:25 PM

この章では、ルーティングに関連する次のトピックを学習します。

CakePHP データベースの操作 CakePHP データベースの操作 Sep 10, 2024 pm 05:25 PM

CakePHP でデータベースを操作するのは非常に簡単です。この章では、CRUD (作成、読み取り、更新、削除) 操作について理解します。

CakePHP バリデータの作成 CakePHP バリデータの作成 Sep 10, 2024 pm 05:26 PM

Validator は、コントローラーに次の 2 行を追加することで作成できます。

See all articles