Monthly Archives: January 2021

Tsugi has Converted from Silex to Lumen

The Tsugi project is mostly libraries (i.e. tsugi-php) but it also has a set of LMS like features like Lessons, Badges, Assignments, etc.  (i.e. koseu-php).  Historically the Koseu tools uses the Silex framework because it was lightweight and allowed the mixing of Silex routes with regular PHP patterns on a path-by-path basis.

But alas, Silex (https://silex.symfony.com/) was written by the same folks who wrote Symfony and tey decided that Silex users should just be converted to Symfony.  Which of course is exactly the opposite of why I chose Silex in the first place.

So Tsugi has been running back-leveled software since 2018.  And as things like PHP versions progressed some of our back leveled software ended up with warning messages that we had to work around.  One back-leveled component causes a ripple effect.

So now we have removed the obsolete software and are using the Lumen framework (https://lumen.laravel.com/) and can advance the versions of PHP and our other dependencies so our stack is more modern.

Time will tell if the Lumen framework or Laravel will help move Tsugi forward.  These frameworks tend to have a sweet spot of the “single monolithic application” instead of allowing a series of smaller cooperating “apps” like Tsugi has become.

 

BREAKING change to Tsugi master branch Monday Jan 18

We have been preparing changes to remove Silex and Twig from Tsugi for some time now and are ready to commit those changes back to master.  Tsugi has used Silex and Twig as a routing and rendering framework for its Koseu tools.  But Silex was abandoned back in 2018:

https://silex.symfony.com/

Tsugi has been holding back some of its dependencies to keep Silex running – but it is time to get back to the present.   We did an evaluation and the closest tool tool to Silex turns out not to be Symfony – but instead a framework called Lumen which comes from the Laravel project:

https://lumen.laravel.com/

The *key* thing I liked about Silex was how you could mix Silex Controllers with regular PHP applications with nothing more than a .htaccess and route file.   You could use Silex for *part* of your application – which is nice.  Lumen works the same way.  It is ironic because Silex came out of the Symfony project.

This new set of dependencies has been tested in a branch for some time now.

We will move these changes into the master branch Monday January 18. I will make a tag so if something goes wrong we can back-level with a “git checkout”.

Preparing for the Upgrade

Preparing for the upgrade is pretty easy. Add one line to your config.php and wait.

require_once $dirroot.”/vendor/tsugi/lib/include/pre_config.php”;
$loader = require_once($dirroot.”/vendor/autoload.php”);

Make this change before Monday and your server should seamlessly upgrade.

If you do not make this change and upgrade after Monday – your site will break. To fix it, edit your config and add that one line …. :)

As a side note, if you followed some of my install patterns and include config-dist.php early and do not pull in the auto-loader in config.php file – you actually don’t have to change anything as the config-dist.php file already includes the pre_config.php changes.

Testing before Upgrade

If you want to test the new code before it lands in master (exactly the same as I am doing in four of my production servers) it is very easy to do.

If you find a problem with the new code – let us know immediately on the tsugi-dev list.

First update config.php as above. Then make sure your tsugi folder is on master and a clean checkout – no modified files – no extra files.

cd tsugi
git status # should be clean
get fetch —all
git checkout —force trunk

Test your code and site – please report if anything goes wrong. To go back to the current master:

git checkout —force master

It is easy to go back and forth as long as your git status is clean.

If somehow the files in the vendor folder seem to be fighting with you as you try to switch branches, take the following steps before or after switching your branch:

cd tsugi
rm -r composer.lock vendor
git checkout composer.lock vendor

You can actually do this any time if your vendor folder gets wonky. It might break for 2 seconds but your vendor folder is nice and fresh.

The trunk branch will be tagged and abandoned after the merge and eventually be removed – so after your testing or after Monday, make sure to go back to master.

Feel free to let me know on the tsugi-dev list if there are any questions.

P.S. The name pre_config.php is slight homage to the movie “Minority Report” :)