Drohano
Drohano

Reputation: 47

How to fix 'Class not found' error in PHP when activating plugin in wordpress?

Me and Some pals have created a wordpress plugin (a formbuilder). we've installed wordpress and uploaded our plugin to cpanel web hosting. Everything works great for everyone localy, however when we activate the plugin to our web host we get this error:

Fatal error: Uncaught Error: Class 'Inc\Api\Callbacks\AdminCallbacks' not found in /home/justforms/public_html/wordpress/wp-content/plugins/Kalkylator/include/Pages/Admin.php:25 Stack trace: #0 /home/justforms/public_html/wordpress/wp-content/plugins/Kalkylator/include/Init.php(33): Inc\Pages\Admin->register() #1 /home/justforms/public_html/wordpress/wp-content/plugins/Kalkylator/kalkylator.php(394): Inc\Init::register_services() #2 /home/justforms/public_html/wordpress/wp-admin/includes/plugin.php(2050): include('/home/justforms...') #3 /home/justforms/public_html/wordpress/wp-admin/plugins.php(175): plugin_sandbox_scrape('Kalkylator/kalk...') #4 {main} thrown in /home/justforms/public_html/wordpress/wp-content/plugins/Kalkylator/include/Pages/Admin.php on line 25

We are using composer and version 5.1.1 on Wordpress.

Here is the call:

namespace Inc\Pages;
/**
 * 
 */

use Inc\Api\SettingsApi;
use Inc\Base\BaseController;
use Inc\Api\Callbacks\AdminCallbacks;

    class Admin extends BaseController
    {
        public $settings;
        public $callbacks;
        public $pages = array();
        public $subpages = array();
        public function register() 
        {
            $this->settings = new SettingsApi();
            $this->callbacks = new AdminCallbacks();
            $this->setPages();
            $this->setSubpages();
            $this->setSettings();
            $this->setSections();
            $this->setFields();
            $this->settings->addPages( $this->pages )->withSubPage( 'All Forms' )->addSubPages( $this->subpages )->register();
        }

Here is the AdminCallBacks's file:

namespace Inc\Api\Callbacks;

use Inc\Base\BaseController;

class AdminCallbacks extends BaseController
{
    public function adminForms()
    {
        return require_once "$this->plugin_path/templates/admin.php";
    }
    public function adminSettings()
    {
        return require_once "$this->plugin_path/templates/settings.php";
    }

Is there something wrong with the call or is does the problem lie within cpanel or Wordpress?

All help is welcome. I'm fairly new to the stack, if there are flaws in the question please notify me so I can improve. Thanks in advance :D

Upvotes: 2

Views: 7533

Answers (1)

Drohano
Drohano

Reputation: 47

I found the problem. Someone commented in this link.

We had forgotten to run Composer in the plugin directory on the live server.

Upvotes: 0

Related Questions