Jorge Castro
2 min readJun 1, 2020

I there:

I am the creator of BladeOne and I actively optimized the framework (that is my main focus) and to be better than Twig.

BladeOne had a problem with the optimization but it was solved (we are in the version 3.44 and you are using the version 3.4).

However, I found 3 conclusions:

  • Unless we are running a high demand site, those benchmarks are really moot. PHP is quite fast even if we use the slow template system. And the bottleneck is usually the database. 🤷‍♀️ (i.e. usually any frameworks works). I think the fastest is Falcon.
  • Twig does a lot of nasty stuff under the hood. Twig is horrible, if you mind optimization (you could check my link, it shows the compiled version).
  • Twig (by default) cache the results in a aggressive stance (it doesn't invalidates cache automatically). I had trouble doing a realistic testing. BladeOne has the same feature but it is optional. BladeOne also allows to cache the result (I think Smarty does the same but nobody use Smarty anymore), right now, I am running a site with lots of page, lots of users in a basic virtual machine, so I optimize it by caching the result, so the template works practically as a static content creator.

Anyways, it is your example with PHP

$data = [      
(object) [
"code" => 200,
"message" => "OK"
],
(object) [
"code" => 404,
"message" => "Not Found"
],
(object) [
"code" => 500,
"message" => "Internal Server Error"
],
]; $html = '<html><head></head><body>';
foreach ($data as $message) {
$html .= "<p>$message->code : $message->message</p>";
}
$html .= '</body></html>';

But it is not fair. Both Twig and Blade encodes the result (and it is one of the reasons why to use a template system).

It is more close to a fair comparison:

$data = [      
(object) [
"code" => 200,
"message" => "OK"
],
(object) [
"code" => 404,
"message" => "Not Found"
],
(object) [
"code" => 500,
"message" => "Internal Server Error"
],
]; $html = '<html><head></head><body>';
foreach ($data as $message) {
$html .= "<p>".\htmlentities($message->code) : ".\htmlentities($message->message)."</p>";
}
$html .= '</body></html>';

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Responses (1)

Write a response