[{"data":1,"prerenderedAt":395},["ShallowReactive",2],{"article_list_php_":3},[4,264],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"publishDate":11,"tags":12,"image":14,"excerpt":10,"body":15,"_type":255,"_id":256,"_source":257,"_file":258,"_stem":259,"_extension":260,"author":261},"/ckeefer/2014-1/still-using-php","2014-1",false,"","Still Using PHP?","Poor PHP. It's so lonely and unloved these days.","2014-01-29",[13],"php","/ckeefer/2014-1/img/php.jpg",{"type":16,"children":17,"toc":252},"root",[18,25,50,72,77,82,87,92,97,104,118,123,128,133,138,143,148,154,184,198,203,209,223,236,247],{"type":19,"tag":20,"props":21,"children":22},"element","p",{},[23],{"type":24,"value":10},"text",{"type":19,"tag":20,"props":26,"children":27},{},[28,30,39,41,48],{"type":24,"value":29},"Well, maybe not lonely - it still undergirds Facebook, Wikipedia and Wordpress, amongst a ",{"type":19,"tag":31,"props":32,"children":36},"a",{"href":33,"rel":34},"http://w3techs.com/technologies/overview/programming_language/all",[35],"nofollow",[37],{"type":24,"value":38},"fair number of others",{"type":24,"value":40},". But, certainly, ",{"type":19,"tag":31,"props":42,"children":45},{"href":43,"rel":44},"http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/",[35],[46],{"type":24,"value":47},"unloved",{"type":24,"value":49}," - and not without some justification.",{"type":19,"tag":20,"props":51,"children":52},{},[53,55,61,63,70],{"type":24,"value":54},"Despite working primarily with Python and Node on the server-side in recent years, I've always had a soft spot in my heart for PHP - I don't actually ",{"type":19,"tag":56,"props":57,"children":58},"em",{},[59],{"type":24,"value":60},"like",{"type":24,"value":62}," it, but I tolerate it for its ",{"type":19,"tag":31,"props":64,"children":67},{"href":65,"rel":66},"http://www.infoq.com/presentations/php-history?utm_source=infoq&utm_medium=QCon_EarlyAccessVideos&utm_campaign=StrangeLoop2013",[35],[68],{"type":24,"value":69},"good points",{"type":24,"value":71},", the way you would an eccentric uncle. PHP was the first web-oriented language I learned, and the thrill of the quick iteration it allowed, when coming from a C and Java background, was not to be denied.",{"type":19,"tag":20,"props":73,"children":74},{},[75],{"type":24,"value":76},"That said, I must still admit that PHP is, to put it nicely, something of a mess.",{"type":19,"tag":20,"props":78,"children":79},{},[80],{"type":24,"value":81},"The problem has always seemd to me to be that its being designed by committee - and one that has a difficult time agreeing on standard conventions, or what other programming language they're trying to ape. Most of my aggravation, petty thought it may be, still stems from its inconsistent function naming (does any given function use_underscores, camelCase or justsquishwordstogether? You won't know until you take yet another trip to the documentation). It also suffers from not being sure whether it wants to be functional or, post PHP 5, object-oriented, and ends up with a sometimes awkward mishmash of the two.",{"type":19,"tag":20,"props":83,"children":84},{},[85],{"type":24,"value":86},"Now, there are any number of programmer posts lamenting the state of PHP (usually written in the aftermath of a painful struggle with some complex legacy project); and most would attribute (or blame) PHP's continued dominance of a large percentage of projects to momentum and availability, rather than being in any way ideal.",{"type":19,"tag":20,"props":88,"children":89},{},[90],{"type":24,"value":91},"I would tend to agree.",{"type":19,"tag":20,"props":93,"children":94},{},[95],{"type":24,"value":96},"The winds of change are blowing though, slow but steady. Instead of yet another condemnation, let's look at some of those recent changes that might mean - whether weighing a rewrite versus continuing to use PHP for a legacy project, or even choosing a server-side language for a brand-new project - PHP might once again take a place amongst the options.",{"type":19,"tag":98,"props":99,"children":101},"h1",{"id":100},"php-fig",[102],{"type":24,"value":103},"PHP-FIG",{"type":19,"tag":20,"props":105,"children":106},{},[107,109,116],{"type":24,"value":108},"There's a lot of talented programmers working in the PHP ecosystem (whether they like it or not), and some big projects filling needed roles. Getting them all to work together would be a huge job - ideally, one that all of the projects involved would cooperate to bring about. For once, the ideal is actualized in the ",{"type":19,"tag":31,"props":110,"children":113},{"href":111,"rel":112},"http://www.php-fig.org/",[35],[114],{"type":24,"value":115},"PHP Framework Interop Group",{"type":24,"value":117},".",{"type":19,"tag":20,"props":119,"children":120},{},[121],{"type":24,"value":122},"Their page starts with a disclaimer that the standards they propose are not necessarily intended for the PHP community at large; but language-wide standards (for coding style, logging and autoloading right now with, I expect, more to come) are exactly what PHP needs.",{"type":19,"tag":20,"props":124,"children":125},{},[126],{"type":24,"value":127},"The autoloading in particular. Importing a library is blessedly easy in Python:",{"type":19,"tag":20,"props":129,"children":130},{},[131],{"type":24,"value":132},"[code lang=\"python\"] from wherever import whatever [/code]",{"type":19,"tag":20,"props":134,"children":135},{},[136],{"type":24,"value":137},"Accomplishing the same in PHP requires some effort to ensure the appropriate source file is included/required before you attempt to reference it in any way. But, if you conform to the autoloading standard, you can just plop at the top of your controller:",{"type":19,"tag":20,"props":139,"children":140},{},[141],{"type":24,"value":142},"[code lang=\"PHP\"] use wherever/whatever; [/code]",{"type":19,"tag":20,"props":144,"children":145},{},[146],{"type":24,"value":147},"For love of all that's good, if you're writing a PHP framework or library, conform to these standards! It will make your target developers lives easier, and make your library easy to discover and adopt.",{"type":19,"tag":98,"props":149,"children":151},{"id":150},"composer-and-packagist",[152],{"type":24,"value":153},"Composer and Packagist",{"type":19,"tag":20,"props":155,"children":156},{},[157,159,166,168,175,177,183],{"type":24,"value":158},"Ah, but how do they discover your library? In keeping with PHP's strong tradition of cribbing from other language's notes, ",{"type":19,"tag":31,"props":160,"children":163},{"href":161,"rel":162},"https://getcomposer.org/",[35],[164],{"type":24,"value":165},"Composer",{"type":24,"value":167}," and ",{"type":19,"tag":31,"props":169,"children":172},{"href":170,"rel":171},"https://packagist.org/",[35],[173],{"type":24,"value":174},"Packagist",{"type":24,"value":176}," would be familiar to anyone who has worked with Node and ",{"type":19,"tag":31,"props":178,"children":180},{"href":179},"npmjs.org",[181],{"type":24,"value":182},"npm",{"type":24,"value":117},{"type":19,"tag":20,"props":185,"children":186},{},[187,189,196],{"type":24,"value":188},"Allowing you to specify the name and versions of the packages you need in the familiar JSON format, composer will automatically download the appropriate packages to a psr-0 or psr-4 compliant structure and generate the autoloader for you to use, making adding other libraries to your project almost painless. Its not sparsely supported, either - Symfony, Doctrine and other big names are available, along with ",{"type":19,"tag":31,"props":190,"children":193},{"href":191,"rel":192},"https://packagist.org/statistics",[35],[194],{"type":24,"value":195},"20,000+",{"type":24,"value":197}," others.",{"type":19,"tag":20,"props":199,"children":200},{},[201],{"type":24,"value":202},"Composer can offer autloading of libraries and frameworks that aren't psr-0/4 compatible as well, along with a number of other capabilities and options. It plays nice with phing for your build process, if you so desire. Give it a look.",{"type":19,"tag":98,"props":204,"children":206},{"id":205},"hhvm",[207],{"type":24,"value":208},"HHVM",{"type":19,"tag":20,"props":210,"children":211},{},[212,214,221],{"type":24,"value":213},"The ",{"type":19,"tag":31,"props":215,"children":218},{"href":216,"rel":217},"http://www.hhvm.com/blog/",[35],[219],{"type":24,"value":220},"Hip Hop Virtual Machine",{"type":24,"value":222}," has created some buzz even in the corners of the net most hostile to PHP (ie. anywhere you find a large number of programmers). Improving the performance of PHP is a worthy goal in and of itself, of course - although it's not yet ready for prime-time, from the figures the hhvm team has posted, it looks like we're well on our way to having a powerful replacement for the Zend engine.",{"type":19,"tag":20,"props":224,"children":225},{},[226,228,234],{"type":24,"value":227},"That said, the real reason I'm excited about having a JITing virtual machine that's 100% compatible with PHP is that ",{"type":19,"tag":229,"props":230,"children":231},"strong",{},[232],{"type":24,"value":233},"we may never need to write PHP again",{"type":24,"value":235}," (and we may live to see the end of posts griping about it, as well).",{"type":19,"tag":20,"props":237,"children":238},{},[239,241,245],{"type":24,"value":240},"What's that you say? - after all this argument as to why PHP might deserve a place at the table, here I am arguing against it? But remember - I don't actually ",{"type":19,"tag":56,"props":242,"children":243},{},[244],{"type":24,"value":60},{"type":24,"value":246}," PHP; the previously mentioned standards and easy access to libraries can make programming in PHP much more tolerable, but can't fix elementary failings of the language. But being able to target the HHVM the way Scala, Clojure, Groovy et al. target the JVM would allow each programmer to pick the language that suits them best - and still get the benefits of easy deployment and compatibility with existing code and libraries.",{"type":19,"tag":20,"props":248,"children":249},{},[250],{"type":24,"value":251},"That would be the best of all worlds - all of PHP's strengths without any, well, PHP.",{"title":8,"searchDepth":253,"depth":253,"links":254},3,[],"markdown","content:ckeefer:2014-1:still-using-php.md","content","ckeefer/2014-1/still-using-php.md","ckeefer/2014-1/still-using-php","md",{"user":262,"name":263},"ckeefer","Christopher Keefer",{"_path":265,"_dir":266,"_draft":7,"_partial":7,"_locale":8,"title":267,"description":268,"publishDate":269,"tags":270,"excerpt":268,"body":271,"_type":255,"_id":389,"_source":257,"_file":390,"_stem":391,"_extension":260,"author":392},"/cmacksey/2012-5/php-musings","2012-5","PHP Musings","Ran into an interesting, but thorough, rant the other day - PHP: A Fractal of Bad Design. The part that grabbed me the most was the analogy at the beginning, which was all too perfect:","2012-05-07",[13],{"type":16,"children":272,"toc":387},[273,286,346,377,382],{"type":19,"tag":20,"props":274,"children":275},{},[276,278,284],{"type":24,"value":277},"Ran into an interesting, but thorough, rant the other day - ",{"type":19,"tag":31,"props":279,"children":282},{"href":43,"rel":280,"title":281},[35],"PHP: A Fractal of Bad Design",[283],{"type":24,"value":281},{"type":24,"value":285},". The part that grabbed me the most was the analogy at the beginning, which was all too perfect:",{"type":19,"tag":287,"props":288,"children":289},"blockquote",{},[290,302,307,319,324,336,341],{"type":19,"tag":20,"props":291,"children":292},{},[293,295,300],{"type":24,"value":294},"I can’t even say what’s ",{"type":19,"tag":56,"props":296,"children":297},{},[298],{"type":24,"value":299},"wrong",{"type":24,"value":301}," with PHP, because— okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.",{"type":19,"tag":20,"props":303,"children":304},{},[305],{"type":24,"value":306},"You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.",{"type":19,"tag":20,"props":308,"children":309},{},[310,312,317],{"type":24,"value":311},"You pull out the hammer, but to your dismay, it has the claw part on ",{"type":19,"tag":56,"props":313,"children":314},{},[315],{"type":24,"value":316},"both",{"type":24,"value":318}," sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.",{"type":19,"tag":20,"props":320,"children":321},{},[322],{"type":24,"value":323},"You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.",{"type":19,"tag":20,"props":325,"children":326},{},[327,329,334],{"type":24,"value":328},"And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it ",{"type":19,"tag":56,"props":330,"children":331},{},[332],{"type":24,"value":333},"completely",{"type":24,"value":335}," worthless. And there’s no clear problem with the set as a whole; it still has all the tools.",{"type":19,"tag":20,"props":337,"children":338},{},[339],{"type":24,"value":340},"Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.",{"type":19,"tag":20,"props":342,"children":343},{},[344],{"type":24,"value":345},"That’s what’s wrong with PHP.",{"type":19,"tag":20,"props":347,"children":348},{},[349,351,356,358,366,368,375],{"type":24,"value":350},"That sums up my feelings fairly completely - there's nothing that doesn't actually get the job done; that, is, everything ",{"type":19,"tag":56,"props":352,"children":353},{},[354],{"type":24,"value":355},"works",{"type":24,"value":357},"; but it's just all quirky and strange and inconsistent.  Further, a lot of the issues are mitigated with a good framework - I prefer ",{"type":19,"tag":31,"props":359,"children":363},{"href":360,"rel":361,"title":362},"http://www.yiiframework.com/",[35],"Yii Framework",[364],{"type":24,"value":365},"Yii",{"type":24,"value":367},", myself, but I hear good things about ",{"type":19,"tag":31,"props":369,"children":373},{"href":370,"rel":371,"title":372},"http://codeigniter.com/",[35],"CodeIgniter",[374],{"type":24,"value":372},{"type":24,"value":376}," as well.",{"type":19,"tag":20,"props":378,"children":379},{},[380],{"type":24,"value":381},"Still, the rant got me thinking. Going through the full list, there seems to me that some of these could be fixed without too much breakage. That is, that they're strange behaviour in corner cases that you wouldn't really do anyway, so what harm would come from changing the behaviour?",{"type":19,"tag":20,"props":383,"children":384},{},[385],{"type":24,"value":386},"Others are more interesting in terms of breakage - function renaming for consistency, for example, or changing argument order in certain functions. Still, I wonder if there's enough demand out there to create a \"cleaner\" version of PHP that fixes some of the glitches, even at the expense of backward compatibility. How much could be done without breaking backward compatibility except in corner cases?",{"title":8,"searchDepth":253,"depth":253,"links":388},[],"content:cmacksey:2012-5:php-musings.md","cmacksey/2012-5/php-musings.md","cmacksey/2012-5/php-musings",{"user":393,"name":394},"cmacksey","Chris Macksey",1780330271164]