You can create any custom class inside your ./app directory without changing anything in your composer.json file, as long the namespace is correct.
For example, let's say you want to name this class MyApiClient, you would create a php file with the same name in the ./app directory, so the file would be ./app/MyApiClient.php
inside this file you should not forget to add the namespace:
<?php
namespace App; // <- important
class MyApiClient
{
// your code
}
When using it, for example in a controller, you just have to import it using the namespace.
<?php
namespace App\Http\Controllers;
use App\MyApiClient; // import using namespace
class TestController extends Controller
{
public function index(MyApiClient $client)
{
// do something
}
}
Composer will autoload the file correctly without needing to change anything in the composer.json file.
There are two old, but good and free, videos about composer autoloading in Laracasts:
https://laracasts.com/series/php-for-beginners/episodes/21 https://laracasts.com/lessons/psr-4-autoloading
Also, if you are a subscriber, there is a video published this week, where they build a Guzzle-based client to consume an external API: