Discussions

News: PHP to Become More Java-Like

  1. PHP to Become More Java-Like (28 messages)

    PHP, the hypertext preprocessor, has had Java-like features for a long time. A PHPBuilder article discusses new features of the upcoming PHP 5.0, which includes a new object model, exception handling, and namespaces. In short, PHP is becoming more like Java.<

    One critical improvement is that PHP classes will support Private, Public and Protected keywords; in PHP 4.3 all variables are effectively public. Another change is that objects will always be passed by reference, never value, which can be done in PHP 4.3. A <code>__clone</code> method will be introduced to create a copy of an object.

    Clearly PHP is becoming more and more capable for powering large-scale web applications. Will we see PHP challenging Java in the enterprise? Only time will tell.

    Threaded Messages (28)

  2. PHP to Become More Java-Like[ Go to top ]

    Ha! I searched the web recently in a desperate attempt to find info on how to scale PHP applications horizontally. I found only some presentation about ppl at yahoo that tried to do that. That presentation depicted vividly several problems and gave no answers nor solutions. In fact in my mind was brewing idea of developing Java envelope for running php code...
    As I know, lots of php sites go down under heavy load. Guys from JBoss experienced the same problem when they tried to use phpNuke as a portal engine for their site and therefore ported phpNuke to run under JBoss. As I understand it's a total rewrite. I'd be very grateful if somebody'd point me to the information on scaling PHP web sites.
  3. PHP to Become More Java-Like[ Go to top ]

    There's probably a way to scale PHP. Sourceforge seems to do it. It may not be easy, and it may not be documented, but it's hard to believe that it's impossible if Sourceforge does it. Maybe they don't have as big of a load as I think. Not sure.

    Steve
  4. PHP to Become More Java-Like[ Go to top ]

    There's probably a way to scale PHP. Sourceforge seems to do it. It may not be easy, and it may not be documented, but it's hard to believe that it's impossible if Sourceforge does it. Maybe they don't have as big of a load as I think. Not sure.


    Maybe there isn't. The latest versions of SourceForge (3.x) are java-based.
  5. thats where its heading towards
  6. PHP to Become More Java-Like[ Go to top ]

    <quote> Maybe there isn't. The latest versions of SourceForge (3.x) are java-based.
    </quote>

    Are you sure about this? It doesn't look like sf.net is running on Java.

    Sandeep.
  7. PHP to Become More Java-Like[ Go to top ]

    Both SourceForge.net as well as SourceForge Enterprise Edition 3.0 - 3.3 are written in PHP.

    Chris Conrad
    SourceForge.net Engineer
  8. PHP to Become More Java-Like[ Go to top ]

    Both SourceForge.net as well as SourceForge Enterprise Edition 3.0 - 3.3 are written in PHP.


    I apologize - I thought I read somewhere that 2.x was PHP, 3+ was java. Is 4.x going to use java or am I just making things up?
  9. <quote>There's probably a way to scale PHP. Sourceforge seems to do it. It may not be easy, and it may not be documented, but it's hard to believe that it's impossible if Sourceforge does it. Maybe they don't have as big of a load as I think. Not sure. </quote>

    Ever try to do a search on SourceForge? 9 times out of 10, the following message pops up: "Our search servers are currently experiencing high load. Please try your search again later."
  10. This is purely a limitation of PostrgreSQL's full text search capabilities and not PHP.

    Chris Conrad
    SourceForge.net Engineer
  11. scaling PHP[ Go to top ]

    I would assume it's the same as scaling Java, or anything else, i.e. write your application so it can be run on multiple servers and then get a load balancer and set up a cluster. This typically means avoiding caching things on the local machine that could be changed on other machines, and using a database as your point of sharing between systems. No big trick. Sites that melt down have probably just not anticipated load very well, and that can happen with any language or development tool.
  12. Ask the people at ObjectWeb[ Go to top ]

    What I know is that the people from ObjectWeb have a project called rubis:
    "RUBiS is an auction site prototype modeled after eBay.com that is used to evaluate application design patterns and application servers performance scalability".

    http://rubis.objectweb.org/

    They also have an implementation in PHP:
    "Several versions of RUBiS are implemented using three different technologies: PHP, Java servlets and EJB (Enterprise Java Bean)".

    If they compare the application with different technologies, they have to know how to scale PHP application as well. It just not fair to distribute the Java based application in 200 clusters and only use one box for PHP, right? ;-)

    Lofi Dewanto
    http://openuss.sourceforge.net
  13. Just because something is not X or not Y does not mean it might not scale or might scale.

    For a "comparison" of PHP, Java/Servlets and EJB you might take a look at RUBiS (Rice University Bidding System). This is just an effort to do some kind of comparsion, as usual: lies, damn lies and benchmarks.

    http://rubis.objectweb.org/

    docs at
    http://rubis.objectweb.org/doc/index.html

    with this paper (this is a bit dated, anyway shows how PHP can scale):
    http://rubis.objectweb.org/download/ebiz_software_comparison.pdf
  14. with this paper (this is a bit dated, anyway shows how PHP can scale):

    > http://rubis.objectweb.org/download/ebiz_software_comparison.pdf

    This paper says nothing about horizontal scaling, nothing about clustering for availability nor performance. All I saw was simple distribution of system' parts into different boxes. It might be ok for many apps, but consider that your system must work 24x7. How you'd achieve this with PHP? I don't know.
    All you're left with PHP is vertical scaling, which costs a lot.
    If developers of PHP would implement session replication on a cluster of Apache+PHP boxes, it'd be VERY great. It'd put PHP into the next level.
    For now, PHP is for small businesses.
  15. How you'd achieve this with PHP? I don't know.

    > All you're left with PHP is vertical scaling, which costs a lot.

    Why's that?

    Just buy 10 boxes that cost about $1000 each and put some intelligent hw-load balancer in front of them. That's it. And for db you can use db providers clustering methods.

    > session replication on a cluster of Apache+PHP boxes

    I have never heard anyone clustering web-servers. I think that more common term should be a farm of web services. Multiple boxes can already share session state with PHP.
  16. Just buy 10 boxes that cost about $1000 each and put some intelligent hw-load balancer in front of them. That's it. And for db you can use db providers clustering methods.

    >
    > > session replication on a cluster of Apache+PHP boxes
    >
    > I have never heard anyone clustering web-servers. I think that more common term should be a farm of web services. Multiple boxes can already share session state with PHP.

    Ok, I'll try to clarify what I meant.
    1) We have load balancer in front of several web servers.
    2) We have several boxes which execute PHP scripts.
    3) We have database box or a cluster of database boxes.

    As I understood, you say that we can replicate session between several PHP boxes??? Not using db for storing session information?
  17. Also, as I know, PHP tightly integrates with Apache. So, there's no way to put processing of PHP scripts into a different machine.
  18. Also, as I know, PHP tightly integrates with Apache.


    Just but some web servers that serve static content on other boxes and Apache (or almost any other web server, eg. Zeus) to serve PHP.
  19. As I understood, you say that we can replicate

    > session between several PHP boxes???

    Yes, you can use shared memory, NFS mounts, Database, or write custom session handler.

    > Not using db for storing session information?

    Db is only one option. Not the only one.
  20. it's so easy[ Go to top ]

    Aapo: Yes, you can use shared memory, NFS mounts, Database, or write custom session handler.

    This reminds me of the computer science books that say "we'll leave this as an exercise for the reader" for all the hard parts.

    Do tell which one of these eliminates all single points of failure, doesn't suffer from a single point of bottleneck, is scalably perfomant, and can be implemented in a day or two.

    Peace,

    Cameron Purdy
    Tangosol, Inc.
    Coherence: Easily share live data across a cluster!
  21. it's so easy[ Go to top ]

    Do tell which one of these eliminates all single points of failure


    I'm not sure what you are after, but clustered db that holds session state for multiple PHP boxes that are placed in front of load balancer eliminates most of them? It's not that hard, Cameron. The point is still that it is not the language that magically makes something scaleable.

    With this configuration, if one PHP box wents down, then other can do it's work and the broken one can be replaced. If db wents down, then there is nothing to do. For db, I'd still suggest to use DBMS providers clustering/replication and caching methods.
  22. JSR-223 To Support PHP 5[ Go to top ]

    Well it appears that Zend the developer of PHP is now moving for even greater integration with Java (note: PHP already has a way to talki to Java). Its first step is to make PHP more object oriented, this comes with PHP 5. The second step seems to be an integration API with Java in the form of JSR-223. Matter of fact, Zend is so committed to this new world view that they're actually going to show up at JavaOne (check out their frontpage).



    http://www.freeroller.net/page/ceperez/20030604#php_moving_towards_tighter_integration
  23. Keep the entry costs low[ Go to top ]

    What I like most about PHP is its low entry costs. It is easy to learn and it is easy to create small-medium sized web applications with. For small web apps and especially with modest development capabilities the time to deployment (or market) is substantially lower than J2EE. It would be great if these strengths are retained even as other features get added to the language. In my opinion this is more important than trying to figure out how to run it in a clustered environment.

    If I want the application to scale and operate in a large corporate environment I would use J2EE. It is already where PHP would like to go. And by the time PHP reaches there, it would have moved on. But to build my own website (which I am building right now) I use PHP.
  24. IMO, using Java for building simple website is just as easy as PHP under these circumstances:
    - Do not think too much on design patterns, MVC architecture, Metadata, Aspects and bla, bla, bla.
    - Just do it quick and dirty. You can use JSP, Templates (Velocity, XMLC) and access your database directly (with pool connection and JDBC), No Struts, Barracuda, Tapestry, EJBs, JMS, XDoclet, AspectJ, etc., etc.

    The problem with Java: everyone think, if someone should start with Java for a simple website, they have to use MVC, Design Patterns and all those bla, bla, bla... These factors make PHP really successful to compete with Java, because all those beginners thought, gosh, Java would be very difficult to learn.

    So:
    Java (under those circumstances) and PHP have just the same entry cost.

    and

    Java with all those buzz words (MVC, Design Patterns, Aspect, Metadata) is not the same as Java with quick&dirty.

    The advantages of Java is that it can scale both in design and performance. So, if you begin with quick and dirty and later on you understand those MVC, Design Patterns, etc. you can upgrade your design system. Also for the performance of the system.

    Lofi.
    http://openuss.sourceforge.net
  25. Actually, the PHP code that I've seen out there is surprisingly well-designed. Reuse, classes, separation of concerns. I'm sure there's a lot of crappy PHP code out there, but the fact that it's a scripting language allows you to refactor at a nice pace. I maintained a PHPShop install once and it was pretty easy to follow.

    Steve
  26. I would disagree big time; I think using Tapestry 3.0 to create simple web sites is easier than using PHP. The new HTML template markup in 3.0 is designed specifically to allow you to create pages quickly and easily without having to be concerned with page specifications and all that initially.

    Unlike PHP, you don't do database access using scripting in the template(unless, I suppose, you create a component to do so, which is quite easy ... and early version of Tapestry included such a component). Doing the database access right in your presentation layer is the big-fat dirty in quick-and-dirty (I like quick, dirty comes back to bite you fast).

    You can write listener methods in Jython instead of Java ... that's quick, for sure.

    Tapestry is about giving you the MVC design pattern so easily and naturally, you don't even notice it.
  27. If I remember correctly I made my first web application within two days of starting to learn PHP (excluding installation time). I think either stripping a J2EE environment of all its frameworks such as MVC, OR-Mapping mechanisms etc and various non essential technologies such as JSTL, Servlets, EJBs etc (dumbed down J2EE) may allow one to approach but not match the low entry barriers to PHP. I havent worked much with tapestry but from what I could infer, it takes a lot of skill and learning curve to get productive with it.

    What I believe is the enhanced features of PHP will allow a migration and scaling path to existing PHP applications or to developer teams who are primarily skilled in PHP. Even for complex applications the low deployment complexities of PHP are likely to score points in its favour though these might be offset by other considerations. However the primary reason PHP has done so well is that it is quick to get in, learn it and get productive (especially with any typical ISP) and I cannot imagine J2EE approaching that capability. There is a business need for low entry cost platforms (probably much larger than we J2EE developers might believe) and PHP meets that. I just wish that PHP does not go down the path of Visual Basic where developers suddenly had to modify their code or had to necessarily understand the new changed syntax to be able to work with the newer versions of VB.

    In summary : IMHO, I dont think dumbed down J2EE or using J2EE with productivity enhancement frameworks (tapestry etc.) help companies in being able to quickly train their teams and get a functional web app quickly. PHP rocks in this space. I hope and pray PHP continues to do the same, while it matures and enhances itself to allow the more skilled developers to do more esoteric things with it.

    Dhananjay
  28. The concept of XTemplates in PHP definitely beats any framework in J2EE for keeping your coding away from HTML.Velocity or Tapestry all have a learning curve but PHP I have seen even web designers can understand easily what they are dealing with in a minimalistic time.
    As I said earlier for low-cost solutions PHP ROCKS!!
  29. PHP is certainly a better option than Java in server side for small firms who are not looking for large scale transactions which would involve EJBs.One of the companies I worked with we had originally JRUN with JSP et al combination which we later replaced with PHP and apaches running on a farm of Linux boxes with a load balancer.It certainly was cheaper and faster.For once we didn't have to deal with JRUN issues(JRUN hanging on overload,the famous connector error).
    And it was faster to develop.I have developed components in both Java and PHP.PHP certainly takes half the time to develop.PHP is ideal to replace JSP I think though I wouldn't consider it as a serious programming language in the level of Java