KillGorack Posted August 6, 2019 Share Posted August 6, 2019 Quick question about the dependency manager Composer with PHP. I have it installed and am pulling in a few libraries, it works pretty well as far as I can tell. I have a question that might be dumb, so I apologize in advance. When connecting to your application it's still required to use the lines similar to the following? <script src="vendor/components/jquery/jquery.min.js"></script> <link rel="stylesheet" href="vendor/twbs/bootstrap/dist/css/bootstrap.css" > Also I'm trying to figure out how to install the x3dom library, but cannot get composer to do it. (https://www.x3dom.org/) Quote Link to comment https://forums.phpfreaks.com/topic/309065-composer-and-my-lack-of-knowledge/ Share on other sites More sharing options...
chhorn Posted August 6, 2019 Share Posted August 6, 2019 (edited) What does HTML/JS have to do with composer? what is "connecting" to an application? What should "but cannot get composer to do it." mean? Edited August 6, 2019 by chhorn Quote Link to comment https://forums.phpfreaks.com/topic/309065-composer-and-my-lack-of-knowledge/#findComment-1568879 Share on other sites More sharing options...
requinix Posted August 6, 2019 Share Posted August 6, 2019 An egregious understatement of what Composer does is that it downloads files. If you need to reference some of those files in your application, notably Javascript or CSS or other client-side assets, then yes: you still have to code that into your application. The bit that Composer does automatically is for PHP classes, which is to create a single file you can include (again, you have to make your application do it) that will automatically pull in whatever classes the libraries provide. To learn how to use x3dom, I suggest starting with the tutorial. 1 Quote Link to comment https://forums.phpfreaks.com/topic/309065-composer-and-my-lack-of-knowledge/#findComment-1568880 Share on other sites More sharing options...
KillGorack Posted August 6, 2019 Author Share Posted August 6, 2019 3 minutes ago, requinix said: An egregious understatement of what Composer does is that it downloads files. If you need to reference some of those files in your application, notably Javascript or CSS or other client-side assets, then yes: you still have to code that into your application. The bit that Composer does automatically is for PHP classes, which is to create a single file you can include (again, you have to make your application do it) that will automatically pull in whatever classes the libraries provide. To learn how to use x3dom, I suggest starting with the tutorial. Thanks, I figured that was the case, just wanted to be sure. I have in the past worked with x3dom similar to that tut, just wanted info on getting composer to download that as well. From bash; dave@dave-main:/var/www/html/PX5$ composer install Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - The requested package components/x3dom could not be found in any version, there may be a typo in the package name. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details. - It's a private package and you forgot to add a custom repository to find it Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems. Quote Link to comment https://forums.phpfreaks.com/topic/309065-composer-and-my-lack-of-knowledge/#findComment-1568881 Share on other sites More sharing options...
KillGorack Posted August 6, 2019 Author Share Posted August 6, 2019 I'm good gotta use NPM, not composer.. ;0) Quote Link to comment https://forums.phpfreaks.com/topic/309065-composer-and-my-lack-of-knowledge/#findComment-1568882 Share on other sites More sharing options...
Zane Posted August 9, 2019 Share Posted August 9, 2019 Composer creates an autoload file that you can include at the top of your PHP scripts instead of having to include every package individually. Then you just have to use them as if they're classes that you've included. https://getcomposer.org/doc/01-basic-usage.md#autoloading Example from site. require ( __DIR__ . '/vendor/autoload.php'; $log = new Monolog\Logger('name'); $log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING)); $log->addWarning('Foo'); 1 Quote Link to comment https://forums.phpfreaks.com/topic/309065-composer-and-my-lack-of-knowledge/#findComment-1568912 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.