Slashdot Mirror


Introduction to PHP5

Yet Another OO Fanatic writes "PHP core developer Sterling Hughes has a excellent presentation (mirror) about PHP5 online. So far it seems to be the best coverage of the new features in PHP5; highlights include the new object model, namespaces, interfaces, access control and exceptions. Java by any other name..."

18 of 338 comments (clear)

  1. new mysql by minus_273 · · Score: 2, Interesting

    just came out too. a decent combination of better features. My only wish: that there was an easier way to do subselects. I knwo almost every one uses the php+mysql+apache combination when doing stuff on linux. I also know that many others like me are really pissd off about the whole subselects thing. I for one have written my own functions to do similar things in php. I knowmany others who have as well. Im sure php developers could produce a standard way of doing it and make it faster.. oh well

    --
    The war with islam is a war on the beast
    The war on terror is a war for peace
  2. And, if you want it right now... by oGMo · · Score: 4, Interesting

    And, if you want it right now, instead of waiting for PHP5, go get Ruby today. It's got all of this, and many more neat features. I've recently been moving PHP over to Ruby, because PHP wouldn't scale to a large project (taking 4-5 seconds to load and generate a page on a hefty server, the codebase was only about a meg and a half of PHP), and because it was incessantly segfaulting for mysterious reasons. I've had no such problems since.

    And ruby's a lot of fun... you can use it for tiny scripts, sites, or large projects.

    --

    Don't think of it as a flame---it's more like an argument that does 3d6 fire damage

    1. Re:And, if you want it right now... by oGMo · · Score: 4, Interesting

      Specifics are about the same. Little over 300 files total (only a small fraction of the complete system unfortunately), about 1.5 meg of code. This is not just a simple database interface, though. It's a complete persistant object system, widget framework, with object access controls, interface building, and the like. It makes development very fast, and lets me do things that would be very difficult with straight PHP (or anything else).

      Unfortunately, when it came to building pages themselves, generating them from objects recursively was the final straw. The times really shot up, although they had been building for some time as the codesize and functionality increased.

      With the new Ruby version, most of the processing, including building the pages, is moved to a backend server (written in Ruby), with a thin layer of CGI (in Ruby) that calls it. Loading the interpreter, parsing, calling the backend, processing, returning, and output is down to half a second on my old p2-350. And the capabilities are far beyond what the PHP version had (although, this was in part due to the fact it's a newer version, but some things PHP's object model would not have been able to handle, such as the integration of any given object, and adding syntax for class and method metadata).

      --

      Don't think of it as a flame---it's more like an argument that does 3d6 fire damage

  3. not really by g4dget · · Score: 2, Interesting

    Java has a static type system (compile-time type declarations). PHP5 presumably still has a purely dynamic type system (but the site isn't responding...).

  4. We need good examples by phorm · · Score: 3, Interesting

    Hopefully... PHP5 will either address some of the common mistakes (without becoming brainless) or at least have some good example out there.

    If anyone has noticed... one of the major areas of death/slashdotting of sites apart from bandwidth are php URL's... and/or mySQL queries (often on PHP URL's). I've not yet noticed many Perl-run pages that have been slashdotted so successfully as PHP.

    Now, I'm not sure if that's a faultof PHP itself, or that some of the "easier" features of PHP tend to attract less competent programmers and/or misconfigurations?

    1. Re:We need good examples by Arethan · · Score: 4, Interesting

      Slashdotting occurs mainly because 1 of 2 things happens. Either a) the pipe to the webserver is too small and the traffic overwhelms their connection; or b) the hardware falls behind in servicing the requests, and thus pages start failing.

      Usually, it's b). Particularly, database queries being the main culprit. When people write database backended websites, they take 1 of two approaches. Make calls to the database every time a page is requested (most used), or they call the database for the first request, caching the result, and feed the cached copy to all other requests that occur within the cache's lifetime.

      Method 1 is easier to do, but is flawed, in that you are placing all of the load on the database server. Once the requests start to pile up, it immediately becomes a bottleneck.

      There was a nice write up about how some group put together a slashdot proof system, consisting of only modest Sun hardware. Their key was the use of java to run the website. Java allowed them to create system-wide objects that could be referenced by unrelated page requests. So they took method 2 in website design, and had a system that only made calls to the database when the cache didn't already hold a requested page.

      PHP4 (and 3), unfortunately, do not allow for persistant system-wide objects. Not even lowly variables. So you can pretty much bet that any stock webserver using PHP will not handle a slashdot link on it's own. It would need a caching server to keep the requests to the database at a minimum. Hopefully, PHP5 will fix this little problem, as even ASP allows for system-wide objects.

      So the short answer to your last question is: It is the fault of the programmer for choosing the wrong model, but PHP doesn't give them any other option, making their only alternative to use a different language.

      Hope that helps. :)

  5. Java? Hardly. by Graelin · · Score: 3, Interesting

    Java by any other name...

    Leave it to a Perl guy to compare PHP to Java.

    features in PHP5; highlights include the new object model, namespaces, interfaces, access control and exceptions.

    Of course, Perl has had all this for some time.

    Just curious, how can you have an object model without namespaces? Or interfaces for that matter? Isn't that like "New Car - with tires!"??

    Either way, PHP makes for a good interface language for web apps - I guess. You can throw it on top of an application layer to do the real work. Last I checked, you could only use SOAP to do this - has anyone tested how well that performs? SOAP doesn't scale all that well.

    It would be nice to let the HTML monkeys handle some of this stuff while the serious development can take place in a real language. /me dawns the flamesuit.

  6. Suexec-like support? by MasterSLATE · · Score: 2, Interesting

    Does anyone know if this version will have better support for suexec-style permissions handling without using php as a perl module script thing? If I'm unclear, what I mean is will php commands like chown and chmod actually be functional on files not owned by the user apache runs as, based on the user who owns the site/scripts?

    --

    [sig]www.masterslate.org[/sig]
  7. Nice and stable by Bob+Bobbinson · · Score: 5, Interesting

    From the blog :

    PHP5 isn't ready

    This is what I get for running a server on pre-alpha software.

    Ok, so as many of you already know, I have my talk for NYPHP online. This talk is hosted on NYPHP's servers, and is running Apache 1.3.27 + PHP5.

    PHP5 leaks worse than the titantic. With MaxRequestsPerChild at 100, apache children grew to 37MB (before we stopped counting). At MaxRequestsPerChild at 40, it was around 27mb. Finally, we've settled on a reasonable default 25 requests per child. MaxClients at 50.

    This is a box that can easily handle 20 times this load. ugh.

    PHP5 is pre-alpha. Don't think otherwise.

  8. Re:Who cares? by Lordrashmi · · Score: 2, Interesting

    Are you a troll or would you care to point out all the security holes?

  9. PHP5 wishlist by Kunta+Kinte · · Score: 2, Interesting

    1 - Better variable scoping features. I'd like to be able to say something like...

    session
    {
    $SessionVar1 = 1;
    $SessionVar2 = y;
    }
    where 'session' is a keyword that executes a block of code or variable declarations in session scope, and have those variables persist throughout the session. Same for application scope, that is variables in that scope persist for the entire life of the PHP engine, and available in all scripts. ( was that the ACLs they were refering to? in the story summary? )

    2 - Built in Opcode caching.

    3 - More consistant library function naming.

    4 - Support for 'taglibs'. The same functionality can be done using functions, well sort of. But this is very usefull when separating the work between web programmers and non-technical designers/maintainers.

    That's my list...

    But yeah, you're right, I should shut-up and code them or stop complaining.

    --
    Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
  10. Where is the unified database interfase ? by mxpengin · · Score: 2, Interesting

    What I would really love to see is a unified database API. It's horrible to have different APIs for each database.

    I know php has odbc support, but ... have you ever tried to make run odbc with mysql in a 100% unix enviroment ?

    Java has JDBC, perl has DBI, Microsoft has ODBC... I am waiting PHP can get something like that !

    --
    "We all know Linux is great...it does infinite loops in 5 seconds." -- Linus
    1. Re:Where is the unified database interfase ? by Christianfreak · · Score: 3, Interesting

      It does of course it still sucks, its not near as powerful as Perl's DBI but its a start and its much better than stupid_function_names()

  11. actually, if you read the article by jbellis · · Score: 2, Interesting

    (here's the pdf) ... many of the changes made bear a striking resemblance to the Java way of doing things Which is hardly a "flame," as one poster accused the article submitter; Java is (still) one of the cleanest language designs around, and gets a LOT of things right.

  12. Re:PHP Is *not* an application server by bahwi · · Score: 3, Interesting

    Best reason not to move to Java: click.

    Programmers determine coding practices, structure, etc. You can find obfuscated java code, obfuscated python, obfuscated perl, or obfuscated php. It all depends on the _programmer_, not the programming language. It's like blaming car accidents on the type of car a person drives.

    Structured code is a good thing though, and so is efficiency.

    Most PHP Projects are put on a shared server, so using shared memory will generally anger the host. For enterprise level, maybe for a simple simple form I'd go with PHP, everything else I would go with something more hardcore, and yes, even Java. Java is a good language, but it's bad to be trapped to a single company for your language.

    Mod_Perl on Apache does shared memory, along with several other improvements. With strict coding practices in a company, and someone going over the code(should be done with _every_ language and _every_ project) the code is easy to read, easy to re-use, and easy to modify. Yes, even Perl. High level enough to do things quickly and easily, and powerful enough to do it very quickly, using shared memory, etc.. Don't underestimate the power of mod_perl, it's easy to get a dynamic database page with mod_perl to load faster than static content.

    And with mod_perl, and good practices(again, necessary even in Java) it will scale easily to multiple servers, legacy systems, etc...

    Of course, we're waiting on Parrot. Yeah, kinda Perl 6, but yeah, it will compile Java. And yeah, cross platform, unlike Java (Java on BSD is a PITA, _and_ reminds me of Win 3.1 on my 33mhz system back in the day).

    So again, the problem is the programmer, not the language. Although you are correct that PHP is not an application server. But look at Parrot and look at Perl, things can grow into even better things.

    Parrot also has a BF (Brain****) interpreter.

  13. Re:PHP Is *not* an application server by Synn · · Score: 4, Interesting

    The "a scripting isn't a REAL programming language" arguement is as tired as it is old.

    I started with Java back when the only IDE out was Symantec's Cafe(not Visual Cafe) and frankly over the years I've found myself to be most productive using scripting languages like perl and php.

    They get things done faster with less code needed to be written in a world where fewer lines of code typically translates into fewer bugs and more productivity per programmer. And I can code in any amount of structure into a project as I see fit.

    Now if I worked in a huge corporation where any idiot could submit code into my project, then yes a language that forces your hand could very well be a good thing.

    But in skilled hands things like strong typing and forced OO really only get in the way.

  14. Scale by Synn · · Score: 4, Interesting

    I'm not too sure what kind of system/traffic your site had, but our company runs web-based apps for over 40 insurance agencies across the US.

    We have one server that hosts 42,000 lines of PHP code and sees around 1300 insurance agents each day who log in, generate term/ltc quotes and download forms.

    Most of the above code drills into a seperate MSSQL database server running Win2k, which actually has become our only bottleneck. That server fails rarely during very high traffic.

    Locally the web server also sports a MySQL database server instance which hosts a little under 5 megs worth of rates for Long Term Care quoting.

    For Term Life quoting I pull in a 50-200k XML datastream from an outside vendor.

    The server hosts 1.7gigs worth of downloadable insurance forms.

    All of this runs on a 1Ghz Pentium 3 with a half gig of ram. A good 300 megs of that ram is currently free.

    In the three years this has been running I've yet to see php cause a crash in apache.

    I'd say it scales pretty damn well.

  15. PHP, Java and Problems with new gimmicks by theolein · · Score: 2, Interesting

    While I must admire the PHP developers for going totally overboard and finally adding features to the almost useless class system they had before, I have found that PHP's great strength has been in smaller websites that need simple code. Java has always been overkill in that arena.

    But what has become an increasingly presistant problem is the way that things that are commonly used such as the easy method of automatic variable creation with reg_globals = on, was changed to be default off and similar things that change in every .x rellease. The problem with that is that you don't know anymore if your code will "just work" on an unknown server, or if you're going to have to change php.ini and /or your code (if you do it the new way and the server is old it won't work and if you do the old way and the server is new...).

    This, in my opinion is starting to defeat the object of what made PHP so popular in the first place: making a small script easily in an easy language for a small site.