1

I am starting a new PHP project and was considering adopting Laravel. Coming from a Java / Spring background I was excited to see a similar MVC / Dependency Injection framework bundling together all the common stuff one normally needs in a web application, in a well structured package. It also seems Laravel is very easy to adopt (easier than Symfony2) when it comes to setting up routes etc.

However, after doing some further research, I am concerned that this framework will introduce a lot of performance overheads and load a lot of things I don't need, making pages slower than they should be. My application will be a typical form-based application, with some database queries and Javascript/AJAX as a front-end. One very important non-functional requirement however is performance. I don't want the page to take a second to load (as long as the database responds quickly obviously).

Either way I intend to use Smarty (partly because I have lots of experience with it and partly because its much more well documented and has much more functionality than Blade, and to me the syntax is slightly cleaner than Twig), although the template engine is not the point of this question really.

Is Laravel truly much slower than say developing a page using a Controller (normal PHP script) with plain PDO and a Smarty template? And what about Laravel compared to a controller with Doctrine2 ORM and Smarty template as the view?

I am a bit new to these frameworks so any information, benchmarks or general description of the overheads that Laravel introduces (versus plain PDO and versus Docrine) would be greatly appreciated.

8
  • You're coming from a Java/Spring background... how much slower did you find using Spring compared with pure homebrew java code? And what benefits did you gain from using Spring? Assess the use of a framework based on the benefits that it gives you rather than performance overhead, because that performance overhead is often a spurious argument because it can be quite insignificant in the greater scale of performance (db access, etc) Commented Sep 9, 2014 at 15:52
  • Laravel + OPcache is quite fast, and you can probably go even faster with HHVM. Commented Sep 9, 2014 at 15:52
  • 1
    Not an answer to your question, but good to know that Laravel 4.3 (the upcoming version) will support route caching, which can cut down on response time (watch laracasts.com/series/whats-new-in-laravel-4-3/episodes/8) Commented Sep 9, 2014 at 15:53
  • @MarkBaker Thanks for your thoughts. Well Java/Spring is a bit of different story for the reason that the a lot of the heavy bootstrapping (and it is quite heavy, a sizeable app can easily take a significant number of seconds) is done on startup, while in the case of PHP a lot is done on receiving the HTTP request for a page, which is what is worrying me most. The benefits obviously are very important when it comes to maintainability and keeping the code clean and without boiler plate (which is why I am considering Laravel). Commented Sep 9, 2014 at 15:58
  • 1
    @jbx Laravel only loads stuff that you actually end up using, for example if you never use any DB::* methods nor models then all the ORM and database-related code won't get loaded, ever. Commented Sep 9, 2014 at 16:44

1 Answer 1

4

It is true that Laravel is slower than pure PHP code, but the network will still almost certainly be your bottleneck.

Blade, Laravel's templating engine, compiles its templates down into PHP, so I wouldn't worry too much about using that. Eloquent, at least in my experience, is a smaller and simpler tool than Doctrine, and if you're still sold on Doctrine, there are a few things that may help. In short, framework overhead isn't huge, and I would gladly accept it in return for faster development.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for answering so fast. Well I am used to using MVC anyway, strictly using PHP scripts as 'controllers' and presentation logic in templates. I am just considering what are the pros of adopting Laravel versus the old approach. I am not sold on Doctrine either, it just seems popular and mature.
I would say that the main benefit is simply not having to reinvent the wheel. Laravel is designed to be a very 'friendly' framework that takes away a lot of the tedious work. Really, not having to write your own routing/MVC/template managing/emailing/etc systems is just very convenient.
Personally I prefer Eloquent to Doctrine: while it has a few quirks (as do most ORMs) Eloquent is as it's name suggests, and even using the query builder, your query code is clean and easily readable (if reasonably formatted); and I'm not a fan of Doctrine's use of Annotations to define relationships
Yeah, the annotations look almost identical to JPA's Entity Annotations, very verbose and make the code look dirty.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.