Tsugi – Non-Upwards-Compatible Change – Using Composer

I made a non-upwards compatible change to Tsugi to move towards refactoring the current monolithic Tsugi code base into separate components. I already factored out the static content (tsugi-static) which is shared between the PHP and Java implementations.

Now I am moving the code that was formerly under lib/vendor into its own repository and have it included using Composer and Packagist.

When you do your next “git pull” or check out a fresh copy, you will need to change your config.php and replace one line:

Remove this line:

require_once($dirroot."/lib/vendor/Tsugi/Config/ConfigInfo.php");

Add this line:

require_once($dirroot."/vendor/autoload.php");

If your Tsugi code explicitly includes anything from lib/vendor/Tsugi (it should not) the fix is to simply remove those includes and allow auto-class loading do work its magic. If you include config.php the auto class loader is in effect.

This makes it so we are loading all the Tsugi classes using the auto loader pattern. Interestingly this allows me to make use of the Tsugi utility code in projects that are not even using LTI.

At this point, I am including the composer.lock file and vendor folder in the Tsugi GitHub repo so that it is a one-stop check out that has the files in their new locations and uses autoloading.

In the long run, I will keep a one-stop-check-it-all out repo but eventually get to the point where a Tsugi tool can stand alone in a repo and have all its dependencies fulfilled by Composer.

If you don’t fix the config.php as described above after you r next git pull, you will see the following error:

Warning: require_once(/Applications/MAMP/htdocs/tsugi/lib/vendor/Tsugi/Config/ConfigInfo.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/tsugi/config.php on line 15

Fatal error: require_once(): Failed opening required ‘/Applications/MAMP/htdocs/tsugi/lib/vendor/Tsugi/Config/ConfigInfo.php’ (include_path=’.:/Applications/MAMP/bin/php/php5.5.10/lib/php’) in /Applications/MAMP/htdocs/tsugi/config.php on line 15

Of course the fix is trivial.