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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.