Is PHP or PHP based web framework stateful or stateless? [closed]
Asked Answered
C

3

8

Along the same lines that for java centric applications, Play framework is stateless and lift framework is stateful as is any servlet or Java EE container like Tomcat or GlassFish is statefull, is PHP web framework like zend or cake php stateless or stateful and why?

Conformity answered 13/6, 2011 at 6:23 Comment(2)
PHP is not a frameworkBelize
PHP is not a framework and is shared-nothing unless you tell it to share via Semaphores, Sessions or other mechanisms.Prevailing
K
22

PHP by itself has no state. Each request is completely unique. It's very close to the bare metal of HTTP in this regard.

To implement state on top of that you can use sessions, databases, shared memory, files or anything else that somehow retains state. Frameworks like Zend or Cake offer abstractions for these mechanisms that make it appear stateful out of the box to varying degrees. PHP is never truly keeping state though.

Kelula answered 13/6, 2011 at 6:38 Comment(0)
A
7

It is not all about Java or PHP. HTTP is a stateless protocol.

To make it stateful, the developer (programmer) has to make sure that all relevant information is stored and make sure that all relevant information is read back in when the script is called upon.

Most of the servers provide session management for stat management.

As to why stateless - stateful session add significant memory and performance overhead see:

models-with-persistent-state-between-http-requests

Ahola answered 13/6, 2011 at 6:53 Comment(0)
A
4

The only 'state' thing in a web application is what's stored persistently somewhere (like a database), the web request-response flow is stateless. It takes from or puts to the persistent storage so it behaves like as if it's stateful. IMHO, session and cookie are included in this persistent storage.

Appurtenant answered 13/6, 2011 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.