Is PHP actually a web framework? [closed]

I was reading an article/interview (Language War: PHP vs. Ruby (by Jeffrey Way; Mar 2011)) by a developer for Envato using Ruby. He says, “PHP is a web framework disguised as a language.”

He didn’t expound on that statement, so it got me wondering if that is true, and if so how. I did a bit of research but couldn’t turn up any information on this topic. I’m wondering how this statement is true and what makes PHP not a programming language. And why do other languages like python or ruby not fit in that category?

9

Officially:

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

According to http://us.php.net/

But that isn’t necessarily a very apt description.

PHP is a Turing complete computer language. However any distribution of PHP is going to come with a huge number of standard libraries, so much so that the standard PHP libraries could be classified as a framework.

Therefore, when looked at in this way, PHP is either:

A framework with its own unique Turing complete scripting language.

Or

A language wrapped in a massive web-framework, from which it can not be removed.

However if we look at the name “PHP: Hypertext Preprocessor” (PHP), this implies that PHP is a “Preprocessor” (that preprocesses Hypertext) – neither a framework, nor a language, but a piece of software.

When you look at it that way, PHP is an application that runs scripts in a proprietary language, with access to a large internal framework designed to process Hypertext.

Therefore: PHP can not properly be classified as either a framework or as a language. The truth is that there is a language, a framework, and an application, that all have the same name (because they are all rolled into one thing)! Thus “PHP” can refer to any part of the system.

3

I don’t have sources – but the statement makes some sense, even if it might just be an attempt to stir controversy.

PHP is definitely a language, and very much not a framework – but if you look at the PHP manual versus, say, the C or C++ specification, the body of functionality that PHP offers has elements that would be considered in the domain of a framework: PDO, XML handling, and so on – this stuff is what would normally be included in a framework like Qt.

9

The thing with PHP is that it’s not just a programming language, but an entire ecosystem, consisting of:

  • The PHP programming language itself
  • A runtime that can hook into a web server (through mod_php or CGI/FastCGI), and provides lots of ways to interact with it
  • A large library of built-in functions and classes, many of them web related

PHP provides features in the language itself that are very specific to web programming, such as the superglobals ($_SERVER, $_GET, $_POST, $_COOKIE, etc.), jumping between PHP mode and HTML mode using <?php ?> tags, etc., and its semantics are built around the one-process-per-request execution model that was the norm back in the early days of server-side web programming. PHP started out as a web scripting tool, and only evolved into a (somewhat) general-purpose programming language later; the CLI version and other non-web features, even though they can often be used quite effectively, are an afterthought, and with enough exposure to the language and its ecosystem, this can become painfully obvious at times.

By contrast, most other programming languages were designed as general-purpose, systems or application programming languages from the beginning, and anything specific to web programming comes in libraries. If you want to do web programming in, say, Python, you need a web framework, or at least a library to implement web server bindings and things like request parsing, HTML templating and session management, and probably some database bindings too (unless you’re really hardcore and write all that from scratch).

PHP has all these things built into it by default, and that’s why people like to say that PHP is a web framework in itself.

For a “Hello, world!” web application in Python, you’d typically set up a virtualenv, install some libraries, set up some boilerplate for the web framework, define routes, and write a handler that generates a response with “Hello, world!” in the body; in PHP, it’s a matter of writing <?php echo "Hello, world!" in index.php, copying it to apache’s docroot, and enabling mod_php. The rest (hooking into the server, parsing requests, generating responses, etc.) still happens, but PHP takes care of it for you.

0

PHP is not a web language. Its has built in features to do programming in Web application. Developing a web application in PHP is very easy compared to other languages like java,ASP,C#.

If you want to develop a web application which is not so huge and uses database with less size (few GB’s) ,then you can develop php web application. There are many web host companies which provide PHP based web hosting charging very less price with all the features.Maintaning a PHP site is less compared to Java/ASP. PHP is light weight web application.

Ryan is probably forming his opinion based on a historical perspective. Historically, PHP was meant to be a web language. Historically a lot of features in the language were designed for this use case, and in fact PHP used to stand for “Personal Home Page”. http://www.nusphere.com/php/php_history.htm

But now, PHP has developed a lot and I would personally argue this isn’t really true any more.

Just 2 examples:

Threads were only added to the language recently. For a long time, it just wasn’t possible. Threads are something that don’t make sense in a web environment (instead you tend to kick of a completely new background process or pass a message through a que to a worker elsewhere). https://www.php.net/manual/en/book.pthreads.php

Memory & Resource management. PHP provides a __destruct() method on objects, so you can clear up resources. But to start with, this was only called on script shutdown. Now in a web environment this makes sense because you only want your script to run 0.5secs at max, so script shutdown is never far away. But for a long running background or shell script this is terrible. Later versions of PHP fixed this. http://php.net/manual/en/language.oop5.decon.php

However, you will still generally tend to find PHP used in a web and server context and not a desktop app context – so this is where a lot of the focus is.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật