News for hackers. Stuff that matters.
Re:PHP 7 Released by brightball on Wednesday December 02, 2015 @10:18AM (#10663408)
Laravel is an excellent Rails clone, but the entire problem with Laravel is that it's a PHP framework.

I've been a PHP dev for 15 years and the biggest issue with frameworks in PHP is PHP itself. A request comes in, the PHP process loads up everything, executes the request and tears down...on every single request.

In just about every other language, the application boots up, loads everything into RAM and each individual request doesn't have to reload things.

There are definitely trade offs here. You can have a 1 TB hard drive filled up with PHP code on a 256mb of RAM server and everything is still going to run fine. There's a lot of value in that and most people who are PHP averse seem to be turning to Lamba from AWS to fill that gap. PHP scales down better than just about anything else out there.

When the other commenter mentioned doing lightweight scripts with PDO that's essentially what he meant though. Lightweight avoids reloading libraries and PHP is lightning fast when you do that.

A lot of progress has been made over the years to help PHP handle frameworks better, but there's a big reason why PHP grinds to a halt with heavy frameworks and that's it. Check out the techempower framework benchmarks.

Using PHP like Go, however, and just pulling in what you need can be extremely powerful.

Here's an entire presentation on it that I gave to a local PHP group. http://www.slideshare.net/barrywjones3/whats-the-right-php

FWIW, I do really like Laravel and even recommend it if you HAVE to use a big framework.

Re:PHP 7 Released by nivla on Wednesday December 02, 2015 @10:50AM (#10663621)
>A request comes in, the PHP process loads up everything, executes the request and tears down...on every single request.

Wouldn't that make debugging much much easier? Since you get a clean slate for every request, bugs can now be tracked and replicated in a saner way. I personally prefer this method for building and maintaining a huge and complex application despite knowing that it may not be an efficient one.

Re:PHP 7 Released by brightball on Wednesday December 02, 2015 @10:58AM (#10663687)
It does, but you get that whether or not you're using a heavy framework.

Without a heavy framework, you get the best of both worlds.

Re:PHP 7 Released by alphadevx on Wednesday December 02, 2015 @10:31AM (#10663509)
> A request comes in, the PHP process loads up everything, executes the request and tears down...on every single request.

It's called the "shared nothing architecture", and its by design. Nothing is shared between requests, so why _not_ tear down?

That model actually has a lot of benefits for web applications (it scales very well), and I consider it one of PHP's strong points.

Re:PHP 7 Released by brightball on Wednesday December 02, 2015 @10:41AM (#10663569)
I do to, except with heavy frameworks.
Re:PHP 7 Released by alphadevx on Wednesday December 02, 2015 @10:55AM (#10663664)
Yep you're right, its the framework bootstrapping that's the killer, especially when those frameworks are expensively parsing config files each time (Yaml, XML...).
Re:PHP 7 Released by spdionis on Wednesday December 02, 2015 @12:44PM (#10664487)
Which modern frameworks never do. The parsed data is usually cached in a php file. Then the (compiled to bytecode) files are cached in opcache. The interpreter doesn't even hit the filesystem on every request.
Re:PHP 7 Released by EGreg on Wednesday December 02, 2015 @02:08PM (#10665081)
With caching, this is actually not such a big problem. The isolation is very good for resilience. Compare, for example, Node.js where a single exception can bring down your entire process and all the requests it's currently executing.

Is Laravel really a Rails clone? I thought that was Symfony. I honestly don't understand why the most popular PHP frameworks are all Rails clones. In my own work, I made things more in a PHP style than Ruby.

Re:PHP 7 Released by brightball on Wednesday December 02, 2015 @04:29PM (#10665977)
That's not a bad thing fwiw. Rails is popular for a reason.
Re:PHP 7 Released by adrianmacneil on Wednesday December 02, 2015 @10:26AM (#10663464)
Pretty sure newer versions of php have an opcode cache built in, so they don't need to load everything on every request now?
Re:PHP 7 Released by brightball on Wednesday December 02, 2015 @10:28AM (#10663483)
Unless something has changed, that's the equivalent of keeping the files in RAM but it doesn't maintain state and routes, etc so it still has to reprocess.
Re:PHP 7 Released by acveilleux on Wednesday December 02, 2015 @10:52AM (#10663635)
That depends on implementation. The cache could be maintained in shared memory, an external process or disk files and in all cases can provide a significant speed up over reading in and compiling hundreds of files without burdening all workers with all compiled opcodes.

The current implementation uses shared memory.

In addition, that does not mean retaining all the variables and data, only the compiled opcodes and that's the bulk of the startup time.