ClickSend / clicksend-php

A wrapper for our REST API - SMS, voice, post, email, fax.
27 stars 14 forks source link

Class Not found #20

Open Shibly opened 4 years ago

Shibly commented 4 years ago

When I install the package through composer and tried for a test call, it says,

Class ClickSend\Configuration' not found

ArcazSuarez commented 4 years ago

I got the same problem. Does anyone know any solution?

jacksegal commented 4 years ago

I had the same issue, but managed to get it working by installing the ClickSend SDK in a fresh project (rather than adding it to a Laravel one).

So there seems to be some sort of clash with the autoload / namespacing?

jacksegal commented 4 years ago

After further investigation I noticed that my fresh project was installing v5.0.64 of clicksend-php but my laravel project was installing v5.0.1.

I tried to manually force my laravel project to install v5.0.64, but I received a guzzle clash:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: guzzlehttp/guzzle[7.1.0, 6.5.x-dev].
    - Can only install one of: guzzlehttp/guzzle[7.1.1, 6.5.x-dev].
    - Can only install one of: guzzlehttp/guzzle[7.1.x-dev, 6.5.x-dev].
    - Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.1.1].
    - clicksend/clicksend-php v5.0.64 requires guzzlehttp/guzzle ^6.2 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - Installation request for clicksend/clicksend-php 5.0.64 -> satisfiable by clicksend/clicksend-php[v5.0.64].
    - Installation request for guzzlehttp/guzzle ^7.1 -> satisfiable by guzzlehttp/guzzle[7.1.0, 7.1.1, 7.1.x-dev].
jacksegal commented 4 years ago

I can get it working on laravel by removing the following require from my composer.json:

"guzzlehttp/guzzle": "^7.1"

It then successfully makes the API call to ClickSend - although not sure which parts of Laravel need guzzle v7

jacksegal commented 4 years ago

Okay, think I've found the best solution:

Waseem-Alhabash commented 4 years ago

@jacksegal Thank You , works like a charm !!

xurizaemon commented 4 years ago

@jacksegal rather than suggesting people use your fork, you can PR your change to the upstream repo

https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request

for me (not using Laravel, so I don't have the same deps as you), the fix was:

# get rid of currently installed 7.x guzzle
composer remove guzzlehttp/guzzle

# require compatible versions of clicksend and guzzle 
composer require clicksend/clicksend-php:^5.0 guzzlehttp/guzzle:^6.2

While the version bump might fix your composer issue, you may or may not find that ClickSend is fully compatible with v7 of Guzzle. The requirement really only wants to be changed if it's required. If ClickSend is compatible with multiple releases of Guzzle then Composer supports multiple versions eg ~6.0 || ~7.0 which would avoid requiring all other projects using the same library to upgrade their Guzzle lib.

jacksegal commented 4 years ago

Thanks @xurizaemon - there is actually already an issue open for them to update their dependencies: https://github.com/ClickSend/clicksend-php/issues/23.

I was just letting people know there was a manual workaround to their problem 👍

xurizaemon commented 4 years ago

I get that, but it's no small task taking on maintenance of a fork; you really should consider

  1. whether the proposed change is required (read above please), and
  2. whether it's less maintenance for you in the long run, and less risk for others, if you get that fix into the core product and off your desk

Best of luck! :grin: