{"id":4892,"date":"2016-01-02T17:55:54","date_gmt":"2016-01-02T21:55:54","guid":{"rendered":"http:\/\/www.dr-chuck.com\/csev-blog\/?p=4892"},"modified":"2016-01-02T17:55:54","modified_gmt":"2016-01-02T21:55:54","slug":"tsugi-non-upwards-compatible-change-using-composer","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2016\/01\/tsugi-non-upwards-compatible-change-using-composer\/","title":{"rendered":"Tsugi &#8211; Non-Upwards-Compatible Change &#8211; Using Composer"},"content":{"rendered":"<p>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.<\/p>\n<p>Now I am moving the code that was formerly under <b>lib\/vendor<\/b> into its own repository and have it included using <a href=\"https:\/\/getcomposer.org\/\" target=\"_blank\">Composer<\/a> and <a href=\"https:\/\/packagist.org\/packages\/tsugi\/lib\" target=\"_blank\">Packagist<\/a>.<\/p>\n<p>When you do your next &#8220;git pull&#8221; or check out a fresh copy, you will need to change your <b>config.php<\/b> and replace one line:<\/p>\n<p><b><\/p>\n<pre>Remove this line:\r\n\r\nrequire_once($dirroot.\"\/lib\/vendor\/Tsugi\/Config\/ConfigInfo.php\");\r\n\r\nAdd this line:\r\n\r\nrequire_once($dirroot.\"\/vendor\/autoload.php\");\r\n<\/pre>\n<p><\/b><\/p>\n<p>If your Tsugi code explicitly includes anything from <b>lib\/vendor\/Tsugi<\/b> (it should not) the fix is to simply remove those includes and allow auto-class loading do work its magic.  If you include <b>config.php<\/b> the auto class loader is in effect.<\/p>\n<p>This makes it so we are loading all the Tsugi classes using the <a href=\"http:\/\/www.php-fig.org\/psr\/psr-4\/\" target=\"_blank\">auto loader pattern<\/a>.  Interestingly this allows me to make use of the <a href=\"http:\/\/do1.dr-chuck.com\/tsugi\/phpdoc\/namespaces\/Tsugi.html\" target=\"_blank\">Tsugi utility code<\/a> in projects that are not even using LTI.<\/p>\n<p>At this point, I am including the <b>composer.lock<\/b> file and <b>vendor<\/b> folder in the <a href=\"https:\/\/github.com\/csev\/tsugi\" target=\"_blank\">Tsugi GitHub repo<\/a> so that it is a one-stop check out that has the files in their new locations and uses autoloading.<\/p>\n<p>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 <a href=\"https:\/\/getcomposer.org\/\" target=\"_blank\">Composer<\/a>.<\/p>\n<p>If you don&#8217;t fix the config.php as described above after you r next <b>git pull<\/b>, you will see the following error:<\/p>\n<p><em>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<\/p>\n<p>Fatal error: require_once(): Failed opening required &#8216;\/Applications\/MAMP\/htdocs\/tsugi\/lib\/vendor\/Tsugi\/Config\/ConfigInfo.php&#8217; (include_path=&#8217;.:\/Applications\/MAMP\/bin\/php\/php5.5.10\/lib\/php&#8217;) in \/Applications\/MAMP\/htdocs\/tsugi\/config.php on line 15<\/em><\/p>\n<p>Of course the fix is trivial.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4892","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/4892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=4892"}],"version-history":[{"count":10,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/4892\/revisions"}],"predecessor-version":[{"id":4902,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/4892\/revisions\/4902"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=4892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=4892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=4892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}