phpsymfonysymfony-2.8mautic

Class not found when it does exist in plugin for Mautic. Works locally but not on staging server


Edit:

There was a weird issue which caused the API file to get renamed with a lowercase 'b' on the server which is why the class wasn't found.


Original Below

I have made a plugin for mautic to check emails for stored contacts within mautic using the NeverBounce API. I have an integration class which gets all the latest unchecked contacts and sends them of to the API, the plugin works perfectly fine locally however when installing the plugin on the staging version and attempting to run the command it fails at finding the NeverBounceApi class.

  [Symfony\Component\Debug\Exception\ClassNotFoundException]
  Attempted to load class "NeverBounceApi" from namespace "MauticPlugin\THNeverBounceBundle\Api".
  Did you forget a "use" statement for another namespace?

I have cleared the cache, ran composer dump-autoload and checked the permissions for the plugin files, everything seems to be in order. The folder structure is as follows:

/PluginBundle
..
--/Integrations
----/NeverBounceIntegration.php
--/Api
----/NeverBounceApi.php
..

NeverBounceIntegration.php

<?php
namespace MauticPlugin\THNeverBounceBundle\Integration;

....
use MauticPlugin\THNeverBounceBundle\Api\NeverBounceApi;

class NeverBounceIntegration extends AbstractIntegration
{
....
    public function getApiHelper()
    {
        if (empty($this->helper)) {
            $this->helper = new NeverBounceApi($this);
        }

        return $this->helper;
    }
....
    public function checkContacts()
    {
        ...
           // it fails when calling the Api class
           $response = $this->getApiHelper()->createJob($list);

    }
}

NeverBounceApi.php

<?php

namespace MauticPlugin\THNeverBounceBundle\Api;

use Mautic\PluginBundle\Integration\AbstractIntegration;
...

class NeverBounceApi
{
    ...
}

Solution

  • There was a weird issue which caused the API file to get renamed with a lowercase 'b' on the server which is why the class wasn't found.