Professional Web Applications Themes

[PHP-DEV] [Proposal] Idea for Application level variables - PHP Development

Hi Davey, I don't know whether this will be implemented in an extension but there are sollutions in userland : to use sysvshm+sysvsem or shmop. The sysvshm+sysvsem extension exposes the C api. I know for 2 wrappers around this API to make the use of shared memory (and thus something like application wide variables) easy to implement in userspace: 1) [url]http://www.php-tools.de/site.php?&PHPSESSID=b4a4ab7142b7d3209c7eee9769120c ba[/url] &file=patMisc/shmc.xml 2)[url]http://www.hristov.com/andrey/projects/php_stuff/shm.php.gz[/url] The second one is written according to PEAR CS. It exposes 4 classes. Shm_Protected_Var is what is needed to implement $_APPLICATION: // masv = my application shared vars. This is the name of the shared var. ...

  1. #1

    Default Re: [PHP-DEV] [Proposal] Idea for Application level variables

    Hi Davey,
    I don't know whether this will be implemented in an extension but
    there are sollutions in userland : to use sysvshm+sysvsem or shmop.
    The sysvshm+sysvsem extension exposes the C api.
    I know for 2 wrappers around this API to make the use of shared
    memory (and thus something like application wide variables) easy
    to implement in userspace:
    1)
    [url]http://www.php-tools.de/site.php?&PHPSESSID=b4a4ab7142b7d3209c7eee9769120c ba[/url]
    &file=patMisc/shmc.xml
    2)[url]http://www.hristov.com/andrey/projects/php_stuff/shm.php.gz[/url]

    The second one is written according to PEAR CS. It exposes 4 classes.
    Shm_Protected_Var is what is needed to implement $_APPLICATION:

    // masv = my application shared vars. This is the name of the shared var.
    // Only the first 4 chars are used to calculate memory address.
    $_APPLICATION = new Shm_Protected_Var("masv", 1024 /*memory*/);
    $_APPLICATION->start_section()
    var_dump($_APPLICATION->getVal());
    $_APPLICATION->end_section();

    Regards,
    Andrey


    ----- Original Message -----
    From: "Davey" <daveyphp.net>
    To: <internalslists.php.net>
    Sent: Thursday, August 07, 2003 3:36 PM
    Subject: [PHP-DEV] [Proposal] Idea for Application level variables

    > Hey,
    >
    > I'm quite new to this, so please don't shoot this down too harshly. If I
    > don't explain something clearly enough, please ask me.
    >
    > Because Application variables are pretty much shared session variables,
    > I wonder if perhaps the session code can be modified to handle these
    > variables.
    >
    > In userland, the implementation would be similar to sessions, and can
    > work on two levels, for a single file or for a group of files.
    >
    > Userland usage examples:
    >
    > // cross file (i.e. an entire website)
    > application_vars_start('my_website'); // my_website is used as the SID
    > $_APPLICATION['website_users'] += 1;
    >
    > // single file
    > application_vars_start(); // uses filename based SID, see below
    > $_APPLICATION['page_users'] += 1;
    >
    > I figured that by using the following in place of the user-input SID,
    > you can easily have page-wide application vars, and by using the arg for
    > application_var_start() in the the place of
    > SG(request_info).path_translated you can have it across whatever you
    > like, problem is when you have multiple sites on the same server,
    > someone else might choose the same name
    >
    > PHP_MD5_CTX context;
    > PHP_MD5Init(&context);
    > PHP_MD5Update(&context, SG(request_info).path_translated,
    > strlen(SG(request_info).path_translated));
    > PHP_MD5Final(key, &context);
    >
    > I don't know if this is clear enough, but in my head at least, it seems
    > a inexpensive solution to something PHP is (in some peoples opinion)
    > lacking. (Note: SRM seems like overkill just for this).
    >
    > Another nice thing about this, as it'll be using the Session
    > infrastructure it could use the session handlers aswell (sqlite, mm etc)
    >
    > one problem that has been mentioned is multi-threaded situations, but I
    > would assume that either the current session code doesn't suffer from
    > this (and therefore neither will this) or that the session code will
    > need to be fixed itself anyways.
    >
    > It should be noted that $_APPLICATION will not be affected during
    > run-time by other scripts changes, i.e. if a.php changes
    > $_APPLICATION['foo'] whilst b.php is running, it doesn't see the changes
    > till the next load... it might be nice to add a function to force a
    > reload of data in the current file though?
    >
    > I'm not sure if you'd consider this to be implemented into the core, but
    > perhaps you could implement it into a PECL extension and then it can be
    > considered for core after it has had some real-life testing/scenarios
    > thrown at it?
    >
    > Just to make it clear, I don't know C/C++ at all, this is just an idea
    > that you might or might not like to implement, I cannot do it (I had
    > help with the MD5 stuff ;).
    >
    > - Davey
    >
    >
    > --
    > PHP Internals - PHP Runtime Development Mailing List
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php

    Andrey Hristov Guest

  2. #2

    Default Re: [PHP-DEV] [Proposal] Idea for Application level variables

    On Thu, Aug 07, 2003 at 02:15:12PM +0100, Davey wrote:
    > Andrey,
    > This isn't quite as transparent as $_SESSION is and $_APPLICATION would
    > also not be a superglobal. What I would like to see at the end of this
    > is a $_APPLICATION variable (or $_APP? some poeple complained that
    > $_APPLICATION is too long) that behaves *exactly* like $_SESSION (in
    > assignment etc) except that its values are available not across
    > sessions but across applications and instances of applications.
    >
    > - Davey
    Check out this one:
    [url]http://www.turcksoft.com/en/e_mmc.htm#api[/url]

    --
    Regards,
    Stefan Walk
    <swalkprp0.prp.physik.tu-darmstadt.de>

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Stefan Walk Guest

  3. #3

    Default Re: [PHP-DEV] [Proposal] Idea for Application level variables

    Stefan Walk wrote:
    > On Thu, Aug 07, 2003 at 02:15:12PM +0100, Davey wrote:
    >
    >>Andrey,
    >>This isn't quite as transparent as $_SESSION is and $_APPLICATION would
    >>also not be a superglobal. What I would like to see at the end of this
    >>is a $_APPLICATION variable (or $_APP? some poeple complained that
    >>$_APPLICATION is too long) that behaves *exactly* like $_SESSION (in
    >>assignment etc) except that its values are available not across
    >>sessions but across applications and instances of applications.
    >>
    >>- Davey
    >
    >
    > Check out this one:
    > [url]http://www.turcksoft.com/en/e_mmc.htm#api[/url]
    MMCache can be used as a session handler, but this still has the
    pitfalls of the other solutions.

    If you were to implement $_APP(LICATION) as suggested, then it could
    indeed (in theory) use MMCache, just as $_SESSION does

    - Davey


    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Davey Guest

  4. #4

    Default RE: [PHP-DEV] [Proposal] Idea for Application level variables


    ] Subject: [PHP-DEV] [Proposal] Idea for Application level variables

    I would love to see an application level superglobal. It's the one
    thing I miss about ColdFusion. Like with CF's shared-scope variables,
    locking will be key, to avoid corruption. (Reading while being
    written to.)

    I'm currently using PEAR Cache_Lite with a named group to emulate but
    it lacks ease of use.

    -Alan


    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php

    Alan Richmond Guest

  5. #5

    Default Re: [PHP-DEV] [Proposal] Idea for Application level variables

    Justin Hannus wrote:
    >So it seems like to get the same functionality, in userland, why not just:
    >
    >$_APPLICATION = &$_SESSION
    >
    >
    Or

    if (!isSet($_SESSION['myApplication'])) {
    $_SESSION['myApplication'] = array();
    }

    $_APPLICATION =& $_SESSION['myApplication'];
    >-Justin
    >
    >"Davey" <daveyphp.net> wrote in message
    >news:20030807141706.32237.qmailpb1.pair.com...
    >
    >
    >>Wojtek Meler wrote:
    >>
    >>
    >>>Davey wrote:
    >>>
    >>>
    >>>
    >>>>MMCache can be used as a session handler, but this still has the
    >>>>pitfalls of the other solutions.
    >>>>
    >>>>If you were to implement $_APP(LICATION) as suggested, then it could
    >>>>indeed (in theory) use MMCache, just as $_SESSION does
    >>>>
    >>>>- Davey
    >>>>
    >>>>
    >>>As far as I understand you just want to have another superglobal
    >>>variable, don't you?
    >>>If so I have small patch witch allow to configure in php.ini names for
    >>>additional superglobals.
    >>>
    >>>Regards,
    >>>Wojtek
    >>>
    >>>
    >>>
    >>Well, whilst this could work, it means that $_APP(LICATION) would not
    >>have the same infrastrcture below it as $_SESSION does (automatic
    >>serializing/unserializing and the ability to switch the data storage
    >>from files, to user, to SQLite and to MMCache)
    >>
    >>- Davey
    >>
    >>P.S.
    >>
    >>Would mind that patch anyways, sounds good, just doesn't fulfill my
    >>needs/desires for $_APP(LICATION)
    >>
    >>
    >>
    >
    >
    >
    >
    >


    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Ken Tossell Guest

Similar Threads

  1. Proposal: Apache::Model2 Web Application Framework
    By Ziya Suzen in forum PERL Modules
    Replies: 0
    Last Post: February 5th, 07:55 PM
  2. Replies: 1
    Last Post: September 3rd, 01:30 PM
  3. Application level variables
    By William Tasso in forum ASP
    Replies: 2
    Last Post: August 13th, 08:06 AM
  4. How to create top-level site/application
    By Amil in forum ASP.NET General
    Replies: 2
    Last Post: July 18th, 06:37 PM
  5. Application-Level Record Locking
    By Bob Barrows in forum ASP Database
    Replies: 2
    Last Post: July 8th, 12:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139