PHPackages                             matt-bartlett/php-spotify-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. matt-bartlett/php-spotify-api

ActiveLibrary[API Development](/categories/api)

matt-bartlett/php-spotify-api
=============================

PHP Package for the Spotify Web API

0.3.0(6y ago)353MITPHPPHP &gt;=7.1CI failing

Since Dec 7Pushed 6y ago2 watchersCompare

[ Source](https://github.com/matt-bartlett/php-spotify-api)[ Packagist](https://packagist.org/packages/matt-bartlett/php-spotify-api)[ Docs](https://github.com/matt-bartlett/php-spotify-api)[ RSS](/packages/matt-bartlett-php-spotify-api/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Spotify PHP Library
===================

[](#spotify-php-library)

This is a framework agnostic PHP library for interacting with the Spotify Web API.

Install
-------

[](#install)

Install using Composer

```
$ composer require matt-bartlett/php-spotify-api
```

Head over to [Spotify](https://developer.spotify.com/dashboard/) and create an application. You'll need the following for later use:

- Spotify Client ID
- Spotify Client Secret
- Redirect URL

Basic Usage
-----------

[](#basic-usage)

This library revolves around `Resources`. Resources encapsulate specific Spotify functionality. Session handling has been abstracted, and while this library ships with it's own session handlers, you are free to write your own and bind it to the implementation. I strongly advise using some sort of dependency container to configure this library. I will go through some examples.

### Generic Example

[](#generic-example)

If you're working in a plain PHP environment, then `examples/vanilla_php_example.php` should cover basic usage of the library.

### Laravel Example

[](#laravel-example)

This library ships with a `LaravelSessionHandler`. This class abstracts the session handler baked into Laravel, allowing you to use the same session driver controlling your application. As Laravel comes with it's own dependency container, we won't have to provide as much configuration. We will however, need to resolve the concrete implementations. We can do that using a service provider.

Create a new service provider within `App\Provider` and paste the following:

```
