Daily Archives: January 14, 2021

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” :)