Giter Site home page Giter Site logo

Class 'Mailgun' not found about mailgun-php HOT 7 CLOSED

mailgun avatar mailgun commented on August 22, 2024
Class 'Mailgun' not found

from mailgun-php.

Comments (7)

airways avatar airways commented on August 22, 2024 9

Just wanted to post a note since the resolution on this issue seems to be pretty incomplete, and this ticket's page is the top google search result for "composer Clas 'Mailgun' not found". The actual problem causing this error appears to be that the sample code does not use the Mailgun namespace. See second line here, which I've updated to have the namespace:

require 'vendor/autoload.php';
$msg = new \Mailgun\Mailgun("key-xxxxxxxxxxxxxxxxxxxxxx");
$mg->sendMessage($domain, array('from' => '[email protected]',
    'to' => '[email protected]',
    'subject' => 'Sent from mailgun title',
    'text' => 'Sent from mailgun message.'));

Without the namespace, the autoloader will not be triggered, and so you get the cited error. The example code appears to be incorrect in README.md and every other page I've seen.

If you carefully review the original issue as reported, zahidilead was clearly both already using composer and including the autoload.php file.

from mailgun-php.

khurshid-alam avatar khurshid-alam commented on August 22, 2024

You need to install mailgun library through composer. And you should use correct path for vendor/autolod in your script.

require 'path/to/file/vendor/autoload.php';

from mailgun-php.

travelton avatar travelton commented on August 22, 2024

Feel free to reach out to Mailgun support for help on this.

from mailgun-php.

jetsetting-stressball avatar jetsetting-stressball commented on August 22, 2024

Just so everyone is aware, I worked this for a few days before figuring it out. This was a good start.

The problem I had was that although my composer file had the Mailgun/Mailgun-php reference in it, I did NOT have the dependencies it needs. See this page for more details:

https://github.com/mailgun/mailgun-php

The three additional references I had to add to my composer.json file, plus Mailgun, are:

"Mailgun/Mailgun-php": "^1.0",
"php-http/curl-client": "^1.0",
"guzzlehttp/psr7": "^1.0",
"php-http/message": "^1.0",

Hope that helps people avoid the issues I did.

-j

from mailgun-php.

Nyholm avatar Nyholm commented on August 22, 2024

Hey @jetsetting-stressball.
Thank you for commenting on this issue. Though, it seams to be unrelated. (See dates for the original post).

About your issue and proposed solution: Did you read this section of the readme? https://github.com/mailgun/mailgun-php#why-requiring-so-many-packages
Have you seen the linked resource in that paragraph?

Composer must have given you a lot of error messages when you were trying to update. Or else you wouldn't get a "class not found".

from mailgun-php.

jetsetting-stressball avatar jetsetting-stressball commented on August 22, 2024

Yup, I read that part of the readme.

Nope, composer didn't give me any errors trying to update. That's why I was confused.

My original error was "Class 'Mailgun' not found", just like this post. Searching for answers I came across this post. It may not be perfectly related, but since I searched and found this page, I figured others may as well... and I'd hate for them to waste two days like I did.

My apologies if that's not the purpose of these communities, just trying to help!

from mailgun-php.

Nyholm avatar Nyholm commented on August 22, 2024

Nope, composer didn't give me any errors trying to update. That's why I was confused.

Interesting.

My apologies if that's not the purpose of these communities, just trying to help!

No need to apologize my friend. You've done nothing wrong. I too are trying to help you and anyone reading this thread after us. That's why I linked to resources, readme and told you about composer.

We should not steal this thread any more. Please open a new issue with your error message, composer file (before and after) and we'll make sure to find the cause of this issue.

from mailgun-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.