Re: Is OOP really appropriate for PHP?



On 2 Dec, 14:56, Viator <varioustr...@xxxxxxxxx> wrote:
Hi folks,

I have a basic question. When I do object-oriented programming
using C++ or Java, all my objects reside in RAM. I do not have
to think about storing and retrieving them, because they are
in RAM and that space has been allocated for them and
the program is continually running, so neither program nor
objects are going to disappear.

As the other correspondents have pointed out - that is the case with
PHP as long as the current thread is being executed. It is also true
of Java and C++ when invoked as a new execution thread via CGI - most
commonly for Java complex applications are implemented via containers
where a significant part of the process continues after the request
thread is completed.

You shouldn't have to think too much about storing/retrieving data
with PHP - read up on sessions. This of course does not address the
class definition part of an object - you can manually reference the
definitions within your code but its a lot simpler to adopt a
consistent approach to where you keep these and use the autoload
functionality (loading of a definition of a class instantiated in the
session is deferred).

however
it takes time to get them out, and to store them back into it.


Most Web based Java applications have a similar problem/overhead
because the session has to replicate across the nodes - IME this is
much more painful than PHP's session handling which is intrinsically
at the storage layer.

(I also have a pet peeve about ORM - I think its a bad idea)

So the question is, I think, appropriate. Since PHP has
(AFAIK) no object storage other than a database, is
OOP in PHP really appropriate?


You don't have to use a database. By default sessions are stored on
the filesystem but you can put them anywhere you can access via PHP -
a database or shared memory are obvious candidates. The filesystem can
easily be in RAM if you like.

Why do you think it's not fast enough?

C.
.



Relevant Pages

  • Re: where do you store app wide data?
    ... > But it still uses and insane amount of RAM. ... process is larger than the PHP process - thats a different story. ... App scope just keeps things in RAM ... >>familiar enough with modern java jit compilers to realise that java runs ...
    (alt.php)
  • Re: Apache vs IIS
    ... Apache/PHP allows you to set session cookies for a whole site, or part of a site if so wanted. ... As I understand to do this in PHP you have to store the values in SESSION cockies then check the SESSION array to see if the value was stored or not. ... But in general ASP.NET is microsoft response to Java. ... Java scripts my self. ...
    (alt.php)
  • Re: [PHP] Persistent Objects
    ... I've been told this is taboo in PHP. ... Coming from Java I'm sure ... implementing form validation, you may want to study up on the strategy ... fetching it from the session each time? ...
    (php.general)
  • Re: sessions being destroyed prematurely
    ... I went and looked into Java headers and other miscellaneous Java ... to directly access the PHP session variables on the server. ... empty array, ...
    (comp.lang.php)
  • Re: how to get object in pages !!!
    ... > functions of java from my php page. ... same operation with $_SESSION also is not ... Try these two scripts to see if sessions are working: ...
    (comp.lang.php)