简体   繁体   English

如何“使用”通过Composer PHP安装的必需依赖项

[英]How to 'use' a required dependency installed via composer PHP

I have installed the SoundCloud API wrapper into my project via composer using composer require ise/php-soundcloud 3.* . 我已经使用composer require ise/php-soundcloud 3.*通过composer将SoundCloud API包装器安装到了我的项目中。 Now in my project, how do I use that? 现在在我的项目中,我该如何使用它? In my composer.json file I have 在我的composer.json文件中

"require": {
        "laravel/framework": "5.0.*",
        "ise/php-soundcloud": "3.*",
        "njasm/soundcloud": "dev-master"
    },

The wrapper I am trying to 'use' is "ise/php-soundcloud": "3.*" . 我试图“使用”的包装是"ise/php-soundcloud": "3.*" The other SoundCloud related file is the wrapper I'm currently using, however I would like to switch over. 其他与SoundCloud相关的文件是我当前正在使用的包装器,但是我想切换。 I am able to 'use' that one by saying use Njasm\\Soundcloud\\SoundcloudFacade; 我可以说use Njasm\\Soundcloud\\SoundcloudFacade;来“使用”那个use Njasm\\Soundcloud\\SoundcloudFacade; at the top of whatever class I am trying to call it from. 在任何我想称呼它的班级中都名列前茅。 But for some reason I am not able to get the other one working, or recognized by my IDE (PhpStorm). 但是由于某种原因,我无法使另一个运行,也无法被我的IDE(PhpStorm)识别。

I teseted this with a fresh L5 install and got phpstorm to recognise it using use Soundcloud\\Service; 我用全新的L5安装对此进行了设置,并使用soundcloud use Soundcloud\\Service; phpstorm识别了它use Soundcloud\\Service; . Seemed to work fine. 似乎工作正常。 To figure it out I looked in the vendor/ise directory and has a look at the Service.php . 为了弄清楚,我查看了vendor/ise目录,并查看了Service.php

This showed it used the Soundcloud namespace. 这表明它使用了Soundcloud命名空间。 If I were to use this properly though I would probably use use Soundcloud\\Service as SoundcloudService just so it woudl make sense. 如果我可以正确使用此功能,尽管我可能会use Soundcloud\\Service as SoundcloudService ,这样才有意义。

This would allow me to use $myScService = new SoundcloudService($clientId, $clientSecret); 这将允许我使用$myScService = new SoundcloudService($clientId, $clientSecret);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM