3 ms·
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 w
by brightball 11y ago
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 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.
- adrianmacneil 11y agoPretty sure newer versions of php have an opcode cache built in, so they don't need to load everything on every request now?
- brightball 11y agoUnless 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.
- acveilleux 11y agoThat 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.
- alphadevx 11y ago> 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.
- brightball 11y agoI do to, except with heavy frameworks.
- alphadevx 11y agoYep you're right, its the framework bootstrapping that's the killer, especially when those frameworks are expensively parsing config files each time (Yaml, XML...).
- spdionis 11y agoWhich 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.
- nivla 11y ago>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.
- brightball 11y agoIt 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.
- EGreg 11y agoWith 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.
- brightball 11y agoThat's not a bad thing fwiw. Rails is popular for a reason.