ReflectionException Class GuzzleHttp\Client does not exist

Posted 3 months ago by nickdavies07

I'm building a composer package in Laravel which uses GuzzleHttp Client to make requests to an API.

I seem to be having an issue trying to get it to work though. It doesn't seem to be able to find the package.

I can't really see what the issue might be - I have the correct namespacing, have required and installed the package and done a composer update. I have done composer dump-autoload as well.

Can anyone see what might be the problem here?

Laravel App composer.json

    "autoload": {
        "psr-4": {
            "NickDavies791\MicrosoftAdapter\": "packages/nickdavies791/flysystem-microsoft/src/",
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "NickDavies791\MicrosoftAdapter\": "packages/nickdavies791/flysystem-microsoft/src/",
            "Tests\": "tests/"
        }
    }

Package composer.json

{
    "name": "nickdavies791/flysystem-microsoft",
    "description": "A Flysystem adapter for Microsoft Graph services.",
    "license": "MIT",
    "authors": [
        {
            "name": "Nick Davies",
            "email": "[email protected]"
        }
    ],
    "require": {
        "guzzlehttp/guzzle": "^6.3"
    },
    "autoload": {
        "psr-4": {
            "NickDavies791\MicrosoftAdapter\": "src/"
        }
    }
}

src/Http/Controllers/GraphTokenController.php

namespace NickDavies791\MicrosoftAdapter\Http\Controllers;

use App\Http\Controllers\Controller;
use GuzzleHttp\Client;

class GraphTokenController extends Controller
{
    /**
     * The HTTP Client instance.
     *
     * @var Client $client
     */
    protected $client;

    /**
     * GraphTokenController constructor.
     * @param Client $client
     */
    public function __construct(Client $client)
    {
        $this->client = $client;
    }

src/routes.php

Route::group(['namespace' => 'NickDavies791\MicrosoftAdapter\Http\Controllers', 'middleware' => ['web']], function () {
    Route::get('graph/token/authorise', 'GraphTokenController')->name('microsoft.token.auth');
});

src/MicrosoftAdapterServiceProvider.php

namespace NickDavies791\MicrosoftAdapter;

use Illuminate\Support\ServiceProvider;

class MicrosoftAdapterServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $this->publishes([
            __DIR__ . '/config/microsoft.php' => config_path('microsoft.php')
        ]);
        $this->loadRoutesFrom(__DIR__ . '/routes.php');
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}

Package Folder Structure

https://i.ibb.co/svFb9d2/flysystem.png

Please sign in or create an account to participate in this conversation.