简体   繁体   中英

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.* . Now in my project, how do I use that? In my composer.json file I have

"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.*" . The other SoundCloud related file is the wrapper I'm currently using, however I would like to switch over. I am able to 'use' that one by saying 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).

I teseted this with a fresh L5 install and got phpstorm to recognise it using 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 .

This showed it used the Soundcloud namespace. If I were to use this properly though I would probably use use Soundcloud\\Service as SoundcloudService just so it woudl make sense.

This would allow me to use $myScService = new SoundcloudService($clientId, $clientSecret);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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