XHP rocks so fucking hard, it isn't even funny. It is just so much better than alternatives. IMHO, It is the only PHP tool I use at facebook that is better than alternatives in other languages. I'm looking at you, django templates! The notation perfectly represents the objects, with no cruft associated with object oriented programming. That is really rare. You could argue that the markup syntax is cruft, but it reall…
XHP: A New Way to Write PHP (from Facebook)
61–70 of 72 posts
Re: XHP: A New Way to Write PHP (from Facebook)
#62Earlier quoted context omitted.
has anyone gotten this to work on OSX? I get strange errors after I build and add the extension to php.ini LOG: http://pastie.org/817528
Working perfectly for me on OS X snow leopard. It compiled cleanly.
However I'm still getting 'xhp_a' class not found errors with the basic tests from the wiki, the same as the other comments in the sibling thread.
It seems to happen on several platforms so its probably a configuration error somewhere.
Any help would be appreciated.
EDIT: Figured it out. You need to include 'init.php' from 'php-lib' in your php scripts. I copied the directory from the xhp source to my site directory and included them from there.
Re: XHP: A New Way to Write PHP (from Facebook)
#63
display this div
display this div instead
This way, you can keep basic logic in your templates (its inevitable and convenient), it's still PHP (there's endforeach, endfor, endwhile, etc.), and this method of templating is very clean.You can now have a class that sets variables through __set(), loads up a .phtml file, starts output buffering, renders the file with those variables, and then returns it.
You can extend it further to automatically sanitize output variables for XSS and whatnot, cache output, etc. This way, you don't need some overly verbose system like smarty to do what PHP does already. XHP just looks like another smarty: solving a problem that I really don't think exists.
Edit: Ok, I probably shouldn't say I dislike this a lot, I do love seeing Facebook sticking with PHP and ultimately helping it out.
Re: XHP: A New Way to Write PHP (from Facebook)
#64Earlier quoted context omitted.
I just installed this on a fresh Linode with a basic Ubuntu 9.10 LAMP stack. It built ok, and the module shows up in phpinfo(), but when I try to run any of the example code, I get an error: Fatal error: Class 'xhp_a' not found in /home/me/public_html/test.php on line 3 Here's the code I tested with: Facebook ; I tried running the code through the xhpize tool, and got the following output: $href,), array('Facebook',)…
I'm having exactly the same problem, same system (Ubuntu Karmic Koala). Prerequisites installed, XHP module installed, it's listed in my phpinfo. For any XHTML tag I include (a, span, ...) the error message says class not included: Fatal error: Class 'xhp_span' not found in ... Any ideas on how to fix would be appreciated. Google and Bing have nothing so far and the module configuration info on the GitHub page is lim…
Re: XHP: A New Way to Write PHP (from Facebook)
#65XHP rocks so fucking hard, it isn't even funny. It is just so much better than alternatives. IMHO, It is the only PHP tool I use at facebook that is better than alternatives in other languages. I'm looking at you, django templates! The notation perfectly represents the objects, with no cruft associated with object oriented programming. That is really rare. You could argue that the markup syntax is cruft, but it reall…
If your code looks anything like that, or the examples on the Facebook page, you're doing it wrong.
Re: XHP: A New Way to Write PHP (from Facebook)
#66XHP rocks so fucking hard, it isn't even funny. It is just so much better than alternatives. IMHO, It is the only PHP tool I use at facebook that is better than alternatives in other languages. I'm looking at you, django templates! The notation perfectly represents the objects, with no cruft associated with object oriented programming. That is really rare. You could argue that the markup syntax is cruft, but it reall…
Re: XHP: A New Way to Write PHP (from Facebook)
#67(Actually, this looks rather handy.. but there is a certain amount of initial WTF.)
Re: XHP: A New Way to Write PHP (from Facebook)
#68Ugh, I dislike this a lot. I'm one of the guys who actually likes PHP, so this may be a bit skewed, but what's wrong with PHP's existing alternate syntax? Most people don't know about it, but it's clean and easy to follow: display this div display this div instead This way, you can keep basic logic in your templates (its inevitable and convenient), it's still PHP (there's endforeach, endfor, endwhile, etc.), and this…
I think I might like the more concise, readable syntax that XHP offers for interpolating {$variables} (and any PHP code for that matter).
Re: XHP: A New Way to Write PHP (from Facebook)
#69Earlier quoted context omitted.
That seems to be unrelated to the concern here (as belied by the grandparent citing magic_quotes). XHP (like plain PHP, for that matter) can be used in a way that, for all intents and purposes, separates the concerns of presentation and logic. It's more a matter of convention than constraint.
> separates the concerns of presentation and logic WHAT? The explicit purpose of this is to combine the presentation (HTML) and logic (PHP) layers.
Re: XHP: A New Way to Write PHP (from Facebook)
#70I would so much rather see (define table (html-table (map [tr (td _)] rows)))
then
$table = ; foreach($rows as $row) { $table->appendChild({$row}); (assuming this is even possible?) }