Download the PHP package matt-bartlett/php-spotify-api without Composer

On this page you can find all versions of the php package matt-bartlett/php-spotify-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-spotify-api

Spotify PHP Library

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

Install

Install using Composer

Head over to Spotify and create an application. You'll need the following for later use:

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

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

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:

Next, in your config/app.php, be sure to add this service provider to the providers array.

We'll need to add our Spotify credentials to our .env file. Replace the values and paste it in.

With everything configured, let's run through some examples.

Client Credential Flow

The Client Credentials authorization flow doesn't require any user authorization in order to generate an access token. Typically, this access token only allows fetching/reading actions, such as finding a Playlist and all it's tracks.

Authorization Code Flow

Actions such as creating a Playlist will need user authorization. In order to obtain to an access token, we must first ask the user to authorize and agree to the actions we wish to perform. Upon confirming, they will be redirected to the redirect_url set on the Spotify\Auth\Credentials class, along with a code we can exchange for an access token.

To demonstrate, I'll add 2 routes to our application. The first route will handle the redirection from Spotify. The second route will create a Playlist.

You may have a dedicated controller that handles redirection. This wouldn't necessarily tie in with a particular Resource. In this event, you can use the Manager.


All versions of php-spotify-api with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
guzzlehttp/guzzle Version ^6.3
nesbot/carbon Version ^2.25
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package matt-bartlett/php-spotify-api contains the following files

Loading the files please wait ....