Live data from Hacker News

PHP 7 deployment at Dailymotion

engineering.dailymotion.com

11–20 of 166 posts

Re: PHP 7 deployment at Dailymotion

#11
post #9
post #5

Wow today is PHP day on HN :)

At least this one isn't ripping it to shreds (so far). The other discussion...that was rough to read as a PHP dev.

I would assume by this point that PHP devs would be fairly confident and comfortable with their decision to continue with PHP and would be used to others bagging on it unnecessarily.

As a JS/Web developer you learn to ignore the hatred of the web that it seems to get from the HN crowd.

Re: PHP 7 deployment at Dailymotion

#12
I used to run one of my site (25K unique visitors a day) on PHP 5.3, when HHVM came out with stable version I shifted to HHVM and I had similar experience. Now I am running it on PHP 7 and I have to say I am more than happy with results. As much as PHP is not cool for today's developers it has served on some really high traffic sites and stayed useful even with the test of time.

P.S. Now I wish somebody just implements a good Async IO system and ability to run HTTP right off the PHP engine (I know there is php -S ...; I am talking about a better async system).

Re: PHP 7 deployment at Dailymotion

#13
At ServerPilot, we decided early on not to support HHVM for similar reasons: we could see PHP 7 was going to offer the same performance benefits without the pain, breakage, and downtime of HHVM.

Early on, before PHP 7 was released, we had to explain this to many of our users who use ServerPilot to host WordPress, Magento, Laravel, and other PHP apps. They often thought there was no downside or risk with HHVM, it was as simple as dropping it in as a replacement. Nowadays, with the hype around HHVM dying down, we don't get requests for HHVM support much anymore.

For a huge company like Facebook, HHVM makes a lot of sense. And the existence of HHVM really sped up the PHP 7 development efforts and provided a great benchmark for how fast PHP 7 could be. So, the PHP community should be very grateful to Facebook for that even if HHVM isn't the future of PHP.

Re: PHP 7 deployment at Dailymotion

#14
Hack and HHVM solves what is, IMO, the worst feature of the default PHP runtime environment[0] - and that is the superglobals.

It wasn't mentioned in the post from Slack, but default superglobals and the earlier register_globals design decisions are the worst and most impactful wart in PHP.

Because it was designed as a templating language, the default web server interface, which is CGI - will auto-expose all variables in global scope, ex.

    echo $_POST['user_id']
PHP has a horrible reputation with security for this reason - we all know that somehow, somewhere, in almost every project someone is pulling in a user-controlled variable from a superglobal and they aren't escaping or checking it properly (since you can't be warned about it but the feature will work).

Worse - and i've seen this a lot, even with Laravel, CodeIgniter, Cake, Symfony/Silex etc. you end up with these well structured projects that declare request classes, methods and variables etc. etc. but then sometime down the road a developer takes a shortcut in a method and pulls in a $_GET or $_POST inside a controller (usually because they don't know how, or aren't bothered to - changing all the related classes) - running around the default exec stack.

I've seen this so often - because it's so easy to do it. The most common place is where a designer has built a frontend AJAX form. They now need to build a quick backend check, so they Google "php backend ajax username check" and they'll likely get a result like this one:

http://stackoverflow.com/questions/29459183/check-username-a...

where the 4th and 5th lines to the solution are:

    $username=$_POST['username'];
    $query="SELECT * FROM username_list WHERE     username='$username' ";
they copy that into a file called ajax_username_check.php and save it to the server - and they've now destroyed all that previous good work by opening up a very blatant and easy to find SQLi vulnerability. Their database will be on pastebin within a month.

You can spot this type of vulnerability from the frontend because the URLs used in the AJAX calls don't match the URL router patterns for the rest of the app (ex. GET /user/username_check_ajax.php vs /user/check_user).

In other languages you can't get that without using a standard library that will escape the values by default. Any solution you search for will always be a safe method to obtain the variable values by default.

Some good news: Hack doesn't expose superglobals in strict mode:

http://cookbook.hacklang.org/recipes/get-and-post/

I'd strongly recommend that this is used in all PHP projects, since it strictly enforces variable access - even in cases where you're using a framework that is supposed to enforce it.

IMO PHP missed a big opportunity with not removing superglobals in version 7 and enforcing an explicit safe request object much like other languages do. They likely wanted to avoid it because of the cluster of register_globals and magic_quotes from earlier versions.

[0] I think it is important to distinguish PHP the language and PHP the runtime. PHP the language is now decent - having caught up with a lot of features (although I find it very verbose and harder to read) while PHP the runtime is undoubtably still a horrible runtime - hence HHVM

Re: PHP 7 deployment at Dailymotion

#15
Had a similar experience deploying HHVM at a previous company, I wrote up a blog post of the issues we ran into / how we worked around them[0]. One thing the dailymotion blog omits is hacklang which has additional features like lambdas, async support (though PHP 7 will soon?), strict typing, collections, generics and more. That said, if you're just trying to squeeze more out of an existing codebase, then PHP7 wins hands down.

[0] https://ma.rtin.so/when-hhvm-doesnt-work-quite-right

Re: PHP 7 deployment at Dailymotion

#16
post #10
post #9

Earlier quoted context omitted.

At least this one isn't ripping it to shreds (so far). The other discussion...that was rough to read as a PHP dev.

Don't take attacks on your usual tool of choice as an attack on yourself. If you think people are making good arguments against PHP, perhaps consider retooling a bit...

Hard to separate yourself from your decisions and your toolset sometimes! I certainly may check out some alternatives at a hobby level and pursue them further if they appeal to me. But for now the money in my rural city is in PHP and to a lesser extend, .NET. Don't think I've ever seen a job asking for Python, Node, etc. that didn't require an hour + commute.

Re: PHP 7 deployment at Dailymotion

#17
post #14

Hack and HHVM solves what is, IMO, the worst feature of the default PHP runtime environment[0] - and that is the superglobals. It wasn't mentioned in the post from Slack, but default superglobals and the earlier register_globals design decisions are the worst and most impactful wart in PHP. Because it was designed as a templating language, the default web server interface, which is CGI - will auto-expose all variable…

Saying that superglobals are the worst thing about PHP is like saying "the worst thing about x86 Assembly is the mnemonics". It misses the point entirely. The worst thing about PHP is that it is fundamentally not well designed and therefore makes developing high-quality software much harder than it needs to be. It also makes developing extremely low-quality software easy, which could be good or bad depending on your perspective.

Re: PHP 7 deployment at Dailymotion

#18
post #12

I used to run one of my site (25K unique visitors a day) on PHP 5.3, when HHVM came out with stable version I shifted to HHVM and I had similar experience. Now I am running it on PHP 7 and I have to say I am more than happy with results. As much as PHP is not cool for today's developers it has served on some really high traffic sites and stayed useful even with the test of time. P.S. Now I wish somebody just implemen…

https://icicle.io

We're currently building a pretty large production system in it. It's got a few warts, but it's damned nice, and it's compatibility with ReactPHP (event-loop, not the front-end tool!) is super useful!

Re: PHP 7 deployment at Dailymotion

#19
post #16
post #10

Earlier quoted context omitted.

Don't take attacks on your usual tool of choice as an attack on yourself. If you think people are making good arguments against PHP, perhaps consider retooling a bit...

Hard to separate yourself from your decisions and your toolset sometimes! I certainly may check out some alternatives at a hobby level and pursue them further if they appeal to me. But for now the money in my rural city is in PHP and to a lesser extend, .NET. Don't think I've ever seen a job asking for Python, Node, etc. that didn't require an hour + commute.

If you're (or anyone else) interested, my company is hiring senior PHP engineers. Modern tech stack: PHP7, MariaDB (MySQL), Redis, distributed workers, Debian, AWS, Solr, data mining/analysis. Competitive salaries, fully remote, vacation, retirement, etc. Contact me at meritt.hn@gmail.com

Re: PHP 7 deployment at Dailymotion

#20
post #12

I used to run one of my site (25K unique visitors a day) on PHP 5.3, when HHVM came out with stable version I shifted to HHVM and I had similar experience. Now I am running it on PHP 7 and I have to say I am more than happy with results. As much as PHP is not cool for today's developers it has served on some really high traffic sites and stayed useful even with the test of time. P.S. Now I wish somebody just implemen…

Can you explain the draw of Async I/O? A single request will not be faster, but you may get more concurrent requests going due to running some while some are waiting for I/O to finish? Is that correct?
Post reply on HN