Luke G Luke G - 1 year ago 74
PHP Question

UserFrosting, Composer & wrong path in includeJSTop

I recently started learning UserFrosting...

I managed to successfully install highlightjs from Packagist using Composer. All went well, new folder and all required files are created in /userfrosting/vendor/components/highlightjs

However, initialize.php and it's includeJSTop() does inject the reference in a path pointing to /public_html/js while files are in /userfrosting/vendor/components/highlightjs

There is a simple solution - to copy highlightjs.js from /userfrosting/vendor/components/highlightjs to /public_html/js but I would like to know if my approach is correct. Or perhaps there is a better way where files are copied to /public_html/js as a part of Composer's install/update.

Answer Source

Composer is for PHP packages. highlight.js is a Javascript package, so it doesn't really make sense to load it using Composer.

There are package managers for Javascript - NPM being the most popular - but UserFrosting 0.3.1 doesn't use those out of the box (UF4 will have integrations for NPM, but that hasn't been released as of the time of this post).

Your best bet for now would indeed be to simply do a "manual install" and copy the highlight.js file to your public/js directory. In that case, you don't need to load it with Composer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download