Making a composer package out of our client

One practice you will start to do a lot is making packages you can use in other projects. In this example, I will start to move the Marvel client into its own namespace and rename it UniversalComicClient. Then, once this is working, I will pull it completely out and put it onto Packagist.

Getting ready

A fresh installation of Laravel is fine. The code for the client can just be moved around in there.

How to do it…

  1. Make a new folder called app\UniversalComicsClient\src as we are going to make this a universal client.

    Tip

    Later, I will rename all of this Comic singular.

  2. Then move the files here:
    • app/UniversalComicsClient/src/MarvelApiClient.php
    • app/UniversalComicsClient/src/ComicClientInterface.php
    • app/UniversalComicsClient/src/MarvelApi.php ...

Get Laravel 5.x Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.