[PHP] Setting up a XDebug debugging environment for PHP / WAMP / Eclipse PDT
Hi list, After struggling a bit to set-up a debug environment in PHP, I decided to write a complete tutorial to explain how to set-up XDebug in a WAMP / Eclipse PDT environment. Everything was already available on the web but was squattered on several different sites. I've tried to write a simple and concise article, and I hope it will benefit the community. It is so confortable to use a break-point in PHP instead of debugging with var_dump! Here is the link to the article: http://blog.thecodingmachine.com/content/setting-xdebug-debugging-environment-php-wamp-eclipse-pdt Enjoy, David. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Facelets for PHP
Hi David, I know at least one framework that can do it. It's called Xaja: http://www.thecodingmachine.com/ext/xaja/doc/ In fact, it is doing much more than just providing facelets since its main purpose is to provide reverse ajax features. It already supports a number of custom tags, and especially, it provides a wrapping of the ExtJS Javascript library. You can have a look at the doc here: http://www.thecodingmachine.com/ext/xaja/doc/widgets/about_widgets.html The technique to write additional components still lacks documentation but if you have a look at the code, it is not that difficult. And I can provide some help. I'm sure there must be other frameworks around providing custom tags. Any one know another one on the list? Regards, David. Disclaimer: I am the main developer of Xaja :) On Wed, 27 May 2009 10:19:42 -0400, David Greenberg greenber...@gmail.com wrote: Hi all, It is very likely that there is already a framework out there somewhere that does this, and that my searches are just too primitive to find it. Please bear with me. I would like to structure a site where every page is written in pure XHTML. In addition to the standard XHTML tag validation, I would like to reference a tag library that allows custom components to be added to a page. For instance: form h1Input here/h1 myns:suggestionInputText / /form I would then like to use PHP to translate this into XHTML that can be sent as an HTTP response. Moreover, I would like to be able to define custom components using XHTML pages. The concept comes from Java Facelets. The main point here is that PHP generates a minimal amount of XHTML/JavaScript for each component, while the pieces are put together by running a PHP program against a pure XHTML file. Is there already a framework within PHP to do this, or would it require custom development? Certainly the possibly implementations are endless, and something like XSLT would be a natural step towards one. I am, however, holding out some hope that a framework already exists, and that I won't need to worry about this. Thank you, David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating A Chat?
Hi Stuart, Indeed, in order to create a chat, you need to be able to push messages from the server to the browser. There are several techniques in order to do that. One is the long polling technique (or Reverse Ajax). It requires a lot of Javascript. The other is going through a Flash server. In both cases, it is quite time consuming to implement correctly those, especially for all browsers. I would advice you to use existing libraries or services in order to implement your chat. Here are 2 solutions: You can try Xaja (http://www.thecodingmachine.com/ext/xaja). This is an open-source Reverse Ajax framework. Or you can use Apideo (http://www.apideo.com). This is service including a Javascript library that can be used to send events across browsers. The service is free for non commercial use. Disclaimer: I've been involved in both project, so this is not a definitive list. There might be other projects allowing you to do so. Regards, David. On Tue, 21 Apr 2009 11:57:08 +0100, Stuart stut...@gmail.com wrote: 2009/4/20 Nitsan Bin-Nun nit...@binnun.co.il: Hi Guys, I have created few chats in the past, but I'm trying to create a new one which saves on HTTP requests and do not become an overkill to the server as more users get in. The chat is a one on one, I'm trying to achieve this: * A user sends a message * The message is not saved/save temporarily on the server * The message is showed to the other user Any ideas how i should implement this? I have no idea how to build it in the most efficiency way, any notes or recommendations or anything that I should pay attention to during development will be very appreciated. Not sure what you mean by chats but is it anything like this... http://pnotes.org/ If so then I'm happy to talk about how I implemented it. Unfortunately I can't release the code because it was developed for a client, but it's pretty simple in concept. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating A Chat?
Here is a quick explanation of what is going on behind the scene: When a client loads the HTML page, a Javascript function is triggered. This function performs an Ajax call to the server. In the case of Stuart, I think he wrote a small fastCgi script that does trap this call (instead of forwarding the call to PHP I Guess). The server does not respond directly. Instead, it does not respond directly, but it keeps the connection to the browser open. When someone else types something in the form, an Ajax call is performed to the server. The fastcgi script receives this message, and sends the message on all the open connections. This technique is known as Comet. You can find a more detailed explanation here: http://meteorserver.org/interaction-modes/ If you want to do the same, there are several options: 1- You do it yourself, like Stuart did. Believe me, this is painful, especially when you want compatibility with old browsers like IE 6, since this involves a lot of Javascript 2- You use a Javascript framework + a light server: Orbited (http://orbited.org) and Meteor-server (http://meteorserver.org) can help you do such a thing. You can also google for the Bayeux protocol that is a standardised implementation of Comet. I think Dojo (http://www.dojotoolkit.org) implements it (not sure though) 3- You use a server side framework that will write Javascript for you. There are several such frameworks in Java. In PHP, the only one I am aware of is Xaja (http://www.thecodingmachine.com/ext/xaja) 4- You decide to use Flash instead, or a framework that use Flash underneath (http://www.apideo.com) 5- You wait for HTML 5 that might, someday (2012?), provide a direct way to do this ;) Regards, David. On Tue, 21 Apr 2009 10:42:54 -0400, tedd tedd.sperl...@gmail.com wrote: At 3:27 PM +0100 4/21/09, Stuart wrote: 2009/4/21 tedd tedd.sperl...@gmail.com: That's about it, isn't it? You know me better than that ;-) It's a live chat system with no flash in sight. No DB either, the whole thing is stored in Memcached. When you post a message it should take no longer than a second to get to all other people present. On the server-side it has a tiny footprint of less than 2MB per 20 concurrent users. -Stuart -Stuart: Yeah, I figured that you would complicate matters considerably. ;-) And there you go again talking about stuff I'm clueless about. Okay, so we all can agree it's a form, right? And visitors can enter stuff, right? So what happens then? Please give me an outline of what happens and use short words. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating A Chat?
Hi Tedd, This is where there is a need for some magic. In the case of Stuart, he wrote a fastcgi script. Basiacally, this handles the Ajax calls. Each call uses long polling: the server is not responding directly. Instead, it keeps the connection open to the fast-cgi script. In order to know how many users are online, you just have to count how many connections are open to the fastcgi script. Then, since the connections are open, still waiting for a reply, the fastcgi script just forwards the message it receives on all open connections. This message is parsed by the Javascript script on the client side, and the Javascript script on the client side adds the message on the screen. There are other ways to do this. I've been doing this in a pure PHP way with Xaja (without the need of using fastcgi, with just PHP and Apache). There is an explanation going on here: http://www.thecodingmachine.com/ext/xaja/doc/about/architecture.html Maybe it will make things more clear. Regards, David. On Tue, 21 Apr 2009 12:10:48 -0400, tedd tedd.sperl...@gmail.com wrote: At 5:14 PM +0200 4/21/09, David Négrier wrote: Here is a quick explanation of what is going on behind the scene: -snip- Regards, David. Thanks -- I think I know what's going on. I've done sufficient ajax to know what's going on. However, what I don't understand is: 1. Detecting who is currently online (i.e., all who are connected to THE server); 2. And then how to send all of them stuff. For example, if you have four people connected to the server at the same time and one sends something, then how do you forward that to each person so that their screen refreshes accordingly? Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating A Chat?
Yes, indeed, the Apache footprint is quite large. Furthermore, with Xaja design, I'm starting 2 processes per connected user. Basically, it requires about 10Mo / user, so the footprint is really bigger than what you are having with pnotes. Currently, it scales quite well up to 100 users (I've never been testing further). The whole interest with Xaja in my opinion is that you can do some Reverse Ajax and Comet stuff without writing a single line of Javascript. And since it uses only Apache and PHP, it's cross-platform. I'll keep an eye on pnotes too, if you plan to keep evolving it. There is only a demo on the web site right now. Do you plan to release it some day? David. On Tue, 21 Apr 2009 17:25:29 +0100, Stuart stut...@gmail.com wrote: 2009/4/21 David Négrier d.negr...@thecodingmachine.com: There are other ways to do this. I've been doing this in a pure PHP way with Xaja (without the need of using fastcgi, with just PHP and Apache). There is an explanation going on here: http://www.thecodingmachine.com/ext/xaja/doc/about/architecture.html Maybe it will make things more clear. Apache has a very big footprint per user, especially when it's using mod_php, so I'd guess you're pretty limited in terms of concurrent connections. The actual use case for the pnotes.org code is expecting several thousand concurrent connections at peak, potentially more. Xaja looks interesting tho, will be looking further into that. Thanks. -Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Announcing Xaja, a PHP Reverse Ajax framework
I don't believe there is an equivalent in other languages. In Java, the closest match might be DWR for the Reverse Ajax approach, or maybe GWT for the no Javascript approach. I'm not completely sure, but I think nobody took exactly the same approach yet, because Xaja opens a large number of processes and connexions and most people believe that its architecture cannot adapt to thousands of users. For my part, since the vast majority of the applications I develop have less than 100 concurrent users, Xaja's architecture is perfect, and I hope it will spread in other frameworks and languages, because I find it really easier to develop applications with a events oriented architecture. David. Sancar Saran a écrit : On Saturday 14 July 2007 15:01:13 David Négrier wrote: Hi I just watching your screen cast, it has very good ideas. I wonder does any other language has same kind of aproach. Later or sooner this kind of aproach become must in web business. Regards Sancar. Indeed, Xaja relies on the keeping of an open connexion between the server and the browser. In fact, it uses, the Comet approach (which is a pain to implement in Javascript because the IE code and the Firefox code are completely different). (more information here: http://www.thecodingmachine.com/cmsDoc/xaja/trunk/architecture.html) The whole idea behind Xaja is to built a complete framework on top of the Comet-like javascript library that will enable the developer to write as few Javascript as possible. So, indeed, through the XajaController object, we are implementing a data driven programming library on top of the classical request/response HTTP protocol. Regarding performances: Indeed, since a connexion is kept open for each browser, this consumes a few connexions on the server (that's not a big problem). Each process also takes some memory. Xaja is still in an early stage of development and I haven't had the opportunity to run a full performance test, but basically, right now, I can tell that a simple applications takes 5 Mo of RAM per client. Which means that for 100 concurrent users, you need 500 Mo of RAM on your server. Now, the vast majority of the servers have less than 100 concurrent users, and at this early point in the development cycle of Xaja, I wouldn't recommend installing Xaja on a server that has more than 100 concurrent users! ;) Regards, David. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Announcing Xaja, a PHP Reverse Ajax framework
Indeed, Xaja relies on the keeping of an open connexion between the server and the browser. In fact, it uses, the Comet approach (which is a pain to implement in Javascript because the IE code and the Firefox code are completely different). (more information here: http://www.thecodingmachine.com/cmsDoc/xaja/trunk/architecture.html) The whole idea behind Xaja is to built a complete framework on top of the Comet-like javascript library that will enable the developer to write as few Javascript as possible. So, indeed, through the XajaController object, we are implementing a data driven programming library on top of the classical request/response HTTP protocol. Regarding performances: Indeed, since a connexion is kept open for each browser, this consumes a few connexions on the server (that's not a big problem). Each process also takes some memory. Xaja is still in an early stage of development and I haven't had the opportunity to run a full performance test, but basically, right now, I can tell that a simple applications takes 5 Mo of RAM per client. Which means that for 100 concurrent users, you need 500 Mo of RAM on your server. Now, the vast majority of the servers have less than 100 concurrent users, and at this early point in the development cycle of Xaja, I wouldn't recommend installing Xaja on a server that has more than 100 concurrent users! ;) Regards, David. Nathan Nobbe a écrit : I understand the use of AJAX to only update a subset of the DOM on a page, rather than rebuild the entire page. What i was getting at though is eliminating the busy-wait model by using the Observer pattern to push changes to the client only when the data has changed on the server side. This is decidedly more efficient in general and is more commonly referred to as *event driven programming* or *data driven programming*. it sounds like the only way to implement such a model over HTTP is by keeping the connection open; which in some circumstances may be appropriate. I have to say though, I never thought of using busy waiting to update just a portion of the DOM. It seems like almost a no-brainier, but since i havent worked w/ AJAX much it just never crossed my mind. That sounds like the most practical approach in general. -nathan On 7/13/07, Tijnema [EMAIL PROTECTED] wrote: On 7/13/07, Nathan Nobbe [EMAIL PROTECTED] wrote: On 7/13/07, Robert Cummings [EMAIL PROTECTED] wrote: This isn't possible since you can't request a connection to the client's machine. Only the other way around. hmm... in that case perhaps the open connection could be employed and the feature used selectively; only on certain pages for instance ? im thinking mainly of a monitoring page; like an app that shows a servers state, or stock quotes or something. the main reason i dont like a javascript timer refreshing the page is sometimes you dont want the whole page refreshed; especially when halfway through filling out a form on the page ;) -nathan Well, that's why AJAX is there, you do a check to a server to see if there's any new data to parse, if so, then you update (and probably only one or two divs on your site, and not the whole page) Keeping connection open isn't quite bad for sites that are visited a lot, as for each connection, a new port is opened to handle a client connection. While you think you're connected to port 80, it is actually redirected to another port (mostly from 3000 onwards). So, if you have a lot of visiters, you might reach the limit of ports, 65536 (0-65535). Some of them are already in use, so you end up to have a limit of about 65530 connections to keep open. For a normal site this isn't a problem, but if you count on shared hosts, with let's say 20 sites, then they can all handle about 3200 connections. Half of the users has probably more then one window open, which means another connection. So you end up to have a maximum of about 2000 visiters at same time for each site. Tijnema On 7/13/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-07-13 at 14:59 -0400, Nathan Nobbe wrote: On 7/13/07, Robert Cummings [EMAIL PROTECTED] wrote: I haven't looked at the code for Xaja and in no way do I want to subtract from its potential, but I'm going to guess that in some way it holds the HTTP connection open and as such is an expensive feature. Also, I'm not entirely sure, but isn't that the principle that Comet uses? As i said ive only imagined such a feature. In my imagination i wonder if it is possible to track the clients address in a data structure within the application. Then a connection could be established whenever a push was needed. This isn't possible since you can't request a connection to the client's machine. Only the other way around. I also think the app would have to track the last page a user requested in order to realize
[PHP] Announcing Xaja, a PHP Reverse Ajax framework
Hi list! A few month ago, I asked a question on this mailing list regarding the closing of a connexion between the PHP server and the browser. Thanks to the answers I was given, I have been able to complete the framework I was working on. Today, I'm proud to announce the first open source alpha release of The Xaja Machine, a full-featured PHP Reverse Ajax framework, at http://www.thecodingmachine.com/projects/xaja. /The Xaja Machine /is a PHP framework that enables the developer to access the most advanced Ajax features very easily. It is a quite big piece of work. It has been in development for more than a year now. Xaja is a *Reverse Ajax* framework, therefore, it enables the server to *push* data directly to the client (just like DWR in the Java world). Furthermore, Xaja changes the way a developer thinks about its application. Instead of being a series of request and responses like any web framework does today, a Xaja application is made of a process on the server side that truly dialogs with the browser. This is a shift in the web paradigm. This is furthermore made easier by an extensible tag library and numerous functions to manipulate the DOM of your web page. The best part of this is you can do that *without typing a single line of Javascript*. Below is a list of features that you will find in Xaja: * *Ajax:* Xaja makes it easy to develop pages with Ajax features. You can develop applications that update the HTML page without having to reload the entire page. * *Pencil:* In order to update the HTML page easily, Xaja provides an innovative method that we called the /Pencil/. Basically, you just tell to Xaja where you would like to write into the page, and you let the application output some HTML using the usual PHP echo function. * *DOM Mapping:* From your PHP application, you can manipulate the Document Object Model (DOM) of the HTML page that is displayed in the browser. You can dynamically add some items, remove other items, etc... Basically, you take control of the browser from the server side. * *Tag library:* To make development easier for the developer, Xaja comes with an extensible tag library. For instance, with Xaja, adding a calendar is as easy as writing calendar /. Furthermore, Xaja adds a number of custom event handlers to standard HTML tags that link directly back to PHP code. * *Reverse Ajax:* Last but not least, Xaja comes with a powerful /message broker/ that enables PHP processes to talk to each other, and a /reverse ajax/ feature that enables a PHP process to talk back to the browser. This makes it easy to develop highly interactive applications like instant messaging, live feeds, or real-time statistics. * *Database ORM tool:* although not part of Xaja directly, Xaja comes bundled with The Database Machine (TDBM). TDBM is a tool that enables the developer to access its database very easily. More information at www.thecodingmachine.com/projects/tdbm http://www.thecodingmachine.com/projects/tdbm Here is a sample using events handling and DOM manipulation: a = input type=text phpvalue=*$a* /br / b = input type=text phpvalue=*$b* /br / a + b = input type=text id=result readonly=true / input type=button value=Compute phponclick=*$xajaController-getWidgetById('result')-value = $a+$b* /br / In this simple adder sample, you will notice the phpvalue attribute that maps directly a PHP variable ($a and $b) to the value of the input field. You will also notice the phponclick attribute that contains PHP code that gets executed as soon as the button is clicked. This sample shows only a small part of the features that Xaja offers. Xaja is still in an early stage of development, but it is time for us to get some feedback (or some help, since it is released in GPL). You can download an alpha version of Xaja from http://www.thecodingmachine.com/projects/xaja You can view a screencast presenting Xaja at : http://www.thecodingmachine.com/cmsDoc/xaja/trunk/screencast.html?group_id=29 Thanks in advance to anyone sending me comments or problems regarding Xaja. Best regards, David. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Announcing Xaja, a PHP Reverse Ajax framework
Hi Mario, hi Stuart, I fixed the SVN repository. You can try it now, it works better. Regarding the way Xaja is pronounced well that's a good question. Actually, I'm French and my pronunciation is... well... French ;), so I won't give you any advice on how to pronounce it. However, I will present Xaja in San Francisco at the Ajax Experience (a conference about Web 2.0 development). I will ask some people there if they can give me a clue on the way to pronounce it in English ;). Best regards, David. Mario Guenterberg a écrit : On Fri, Jul 13, 2007 at 10:10:15AM +0200, David Négrier wrote: Xaja is still in an early stage of development, but it is time for us to get some feedback (or some help, since it is released in GPL). You can download an alpha version of Xaja from http://www.thecodingmachine.com/projects/xaja You can view a screencast presenting Xaja at : http://www.thecodingmachine.com/cmsDoc/xaja/trunk/screencast.html?group_id=29 Thanks in advance to anyone sending me comments or problems regarding Xaja. Hi... I will test your framework but the checkout for the svn repo don't accept the username and password documented in the website. :-( Greetings Mario -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing a connection to browser without exiting the script
Hi All, Thanks a lot for your numerous answers. I've learned a lot from all your suggestions. Actually, combining all your answers, I'll come up with a solution. To be more explicit on what I want to do, I want in fact to start a script, I want that script to display a page, and then, I want that script not to stop, but I want to be able to access that script back using AJAX calls from the web page. So my script is opening a network connection after having displayed the web page and is waiting for incoming calls. Although no solution given here is fully satisfying (because I don't want to launch antother script, I want to remain in the same) I still can find a way to close my connection to the browser (using a header specifying the connection length) and then go back to my script using AJAX. Thanks a lot for the time you took to propose solutions. Best regards, David. www.thecodingmachine.com Eric Butera a écrit : On 11/1/06, David Négrier [EMAIL PROTECTED] wrote: Hello there, I'm having a somewhat unusual question here, and I cannot find any way to solve it. I have a PHP page that displays a message, and then, performs a very long operation. Note that it displays the message first. I do not intend to give some feedback to the user when the operation is done. I've seen I can use ignore_user_abort() to prevent the user from stopping the ongoing operation, but that solves only part of my problem. Because as long as the page is not fully loaded, the mouse cursor in the user's browser is showing a watch. So ideally, what I would like is to be able to close the connection from the server-side, but without using the exit() function, so my script keeps running afterwards. I know I could use a system() call to launch another process to do the processing, but I would like to avoid doing that, because there are many variables in the context that I cannot easily pass in parameter. I also tried to use the register_shutdown_function() to perform my operation after the page is displayed but since PHP 4.1.0, the connection is closed after the function is called Would any of you have an idea on how I could close that connection? Thanks a lot, David www.thecodingmachine.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you haven't gone with any of the listed methods yet you could use fsockopen with a timeout value to accomplish your goal. frontend.php: ?php $fp = fsockopen(localhost, 80); fwrite($fp, GET /long_processing_script.php HTTP/1.0\r\n\r\n); stream_set_timeout($fp, 1); echo done!; ? long_processing_script.php: ?php ignore_user_abort(); set_time_limit(0); // do stuff here ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Closing a connection to browser without exiting the script
Hello there, I'm having a somewhat unusual question here, and I cannot find any way to solve it. I have a PHP page that displays a message, and then, performs a very long operation. Note that it displays the message first. I do not intend to give some feedback to the user when the operation is done. I've seen I can use ignore_user_abort() to prevent the user from stopping the ongoing operation, but that solves only part of my problem. Because as long as the page is not fully loaded, the mouse cursor in the user's browser is showing a watch. So ideally, what I would like is to be able to close the connection from the server-side, but without using the exit() function, so my script keeps running afterwards. I know I could use a system() call to launch another process to do the processing, but I would like to avoid doing that, because there are many variables in the context that I cannot easily pass in parameter. I also tried to use the register_shutdown_function() to perform my operation after the page is displayed but since PHP 4.1.0, the connection is closed after the function is called Would any of you have an idea on how I could close that connection? Thanks a lot, David www.thecodingmachine.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php