Chamilo 1.11 on Raspberry Pi 3 for off-the-grid situations

This article can be considered an update of our first article on installing Chamilo (on a Raspberry Pi B+). This time, we are testing it with Raspberry 3, as of the 1st of April 2017 (no joke intended). Last time, we were testing with Chamilo 1.9, which is arguably less load-intensive, considering it doesn't include any Symfony component, and it doesn't require any .htaccess configuration.

Versions of PHP in Ubuntu

If you have to maintain an open source project written in PHP, like we do with Chamilo at BeezNest, you'll have to test your software on multiple versions of PHP to make sure of how well your code is supported on these versions. Of course, being open source, you can publish it on Github and then benefit from Travis-CI to get tests run automatically, but some stuff might be tricky to do, and maybe you'd like to test one specific thing, quickly, under a specific PHP version. Well, it turns out you can probably do that with Docker.

Benchmark: dirname(__FILE__) vs __DIR__ in PHP

dirname(__FILE__) and __DIR__ give exactly the same result in PHP, although one (__DIR__) is evaluated at compile-time, while the other (dirname(__FILE__)) has at least part of it (the function) evaluated at execution time. Ever wondered what the difference is, in terms of efficiency, between the two? I've written a *very* simple script to try it out:
<?php
$loops = 100000000;
echo 'Testing dirname(__FILE__)' . PHP_EOL;
$start = time();
$dir = '';
for ($i = 0; $i < $loops; $i++) {
 $dir = dirname(__FILE__);
}
echo 'dirname(__FILE__) took ' . (time()-$start) . 's' .

Prevent Wordpress MailmanWidget widget to hide after registering your address

If you use the Mailman Widget as an important design element, you might be annoyed by the fact it disappears once you registered your e-mail. A quick hack to this behaviour is to modify ns_widget_mailman.class.php (see comments):
 public function widget ($args, $instance) {
     extract($args);
     // Patch to continue showing block even if registered in this session
     //if ((isset($_COOKIE[$this->id_base . '-' . $this->number]) && $this->hash_mailing_list_id($this->number) == $_COOKIE[$this->id_base . '-' .

Can't use function return value in write context

Did you ever develop some nice code, then simply wanted to check if a string was only composed of white spaces or tabs, and used something like this:
if (!empty(trim($string))) { ... }
...only to get a bad error appear (only on your PHP 5.4 server) in the middle of your app, like this?:
Fatal error: Can't use function return value in write context
Well, this has a simple explanation... Prior to PHP 5.5, the empty() function did not accept something else than a variable.

Creating new tasks in chamilo course-sessions

In the category of little scripts that can make your life easier when managing huge Chamilo portals, this is a little one that creates one tasks-folder called "ALP" for the "Assignments" (work) tool in each active course for a portal where you have thousands of sessions, with one course per session. The script works for version 1.9.8 of Chamilo, but might need some adaptations to run on an older version, in particular considering the addDir() function from the main/work/work.lib.php library which was created there recently. You should put the file into any "one-level" directory under the Cha

On PHP and cache slams and solutions

While reading about Doctrine's cache mechanism (which applies to other stuff than database queries, by the way), my eye was caught by a little message at the end (last section) about cache slams. I have used cache mechanisms extensively over the last few years, but (maybe luckily) never happened to witness a "cache slam". There's a link to a blog (by an unnamed author) that explains that. To make it short, you can have race conditions in APC (and

PHP's call_user_func_array() is slow

I just solved an issue that had me waking up in the middle of the night for weeks (just pushing it a bit) and I have to thank PHP's community and in particular a guy named Brad Proctor for writing a very short but very important comment in the PHP manual, and I quote:
This function is relatively slow (as of PHP 5.3.3) and if you are calling a method with a known number of parameters it is much faster to call it this way: $class->{$method}($param1, $param2);
He mentions