dcarrith / lxmpd

Laravel wrapper for a xMPD class
MIT License
2 stars 3 forks source link

HOWTO #1

Open rawzone opened 8 years ago

rawzone commented 8 years ago

Hello,

After some time trying to figure out how to make this code connect to a running mpd daemon I'm on the edge of giving up.

I've have taken these steps as of now:

composer require dcarrith/lxmpd
php artisan vendor:publish --provider="Dcarrith\LxMPD\LxMPDServiceProvider"

After this i changed the config to the right info for connecting to the mpd daemon

Dcarrith\LxMPD\LxMPDServiceProvider::class,

in the app.php provicers array

Also tried to mock around setting up an alias to the facades but no luck figuring that one out either.

'lmpd' => Dcarrith\LxMPD\LxMPDFacade::class,

Can't wrap my brain around how to move on from here. Could you give me any hints?

Thanks in advance!

dcarrith commented 8 years ago

@rawzone - Have a look at how I use it in my other project MPDTunes.

https://github.com/dcarrith/mpdtunes/blob/master/app/config/app.php https://github.com/dcarrith/mpdtunes/blob/master/app/config/packages/dcarrith/lxmpd/config.php https://github.com/dcarrith/mpdtunes/blob/master/app/controllers/MPDTunesController.php

I don't remember if I've pushed all the latest changes to the mpdtunes project to github. But, I do know that last time I did push, everything was working. However, an issue did come up after I upgraded to Laravel 5.x (it wasn't able to connect to MPD because it wasn't getting the configs from the Config facade like it did in Laravel 4.x). I just haven't had time to look into it.

Oh wow, yeah, looks like I haven't pushed since I upgraded to Laravel 5.x. That's mainly because I haven't had time to get everything working again.

dcarrith commented 8 years ago

The underlying issue probably has something to do with my use of the Config facade inside the LxMPD package @ line 53: https://github.com/dcarrith/lxmpd/blob/master/src/Dcarrith/LxMPD/LxMPDServiceProvider.php

If I remember correctly, that is the piece that broke with the upgrade to Laravel 5.x.

If you can figure out how to (update my code for the LxMPD package) so it retrieves the config variables for host, port and password in the new Laravel 5.x way, then you should be good to go.

It's worth the effort. The LxMPD package really does offer a pretty clean way to control the MPD daemon. Have a look at the control function in this file for many examples (you can skip all the mpd idle stuff if you're not trying to use websockets like I am): https://github.com/dcarrith/mpdtunes/blob/master/app/controllers/MPDController.php

rawzone commented 8 years ago

@dcarrith thanks for the snappy answer..!

I will try to look a bit more on the code and see if i can come up with a way to get it working under Laravel 5.x.

The example code helped me understand things a bit better indeed. Ill keep you updated (make a pull request) if things get to a working state.

Thanks again.

craigjmidwinter commented 8 years ago

@rawzone, I was able to get this working with Laravel 5.2. As @dcarrith mentioned, changes were needed to how the config values were accessed. I just made a pull request with the change-- https://github.com/dcarrith/lxmpd/pull/2/files

If it still doesn't work after making the change and running php artisan vendor:publish, make sure that you can connect to the MPD through telnet or something (I only mention this because while I was debugging this I ran into an issue where my MPD wasn't starting correctly and I kept seeing 'Connection Refused' in the logs).

rawzone commented 8 years ago

@wardcraigj Very nice - Thanks for keeping me informed. Will next week have some time for this project again and I'll test out your pull and see if I can get things going whit that.

Again - Thanks a ton for the info!

craigjmidwinter commented 7 years ago

@rawzone-- In case you still look for it-- I just closed that PR and created a new one from a separate branch so I can commit to my fork's master without impacting the PR. The link is here: https://github.com/dcarrith/lxmpd/pull/3/files