2

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

Drohano
  • 47
  • 1
  • 6
  • where are your requires? do you have autoloader? – treyBake Apr 26 '19 at 11:02
  • @treyBake we're using autoloader. – Drohano Apr 26 '19 at 11:08
  • huh.. weird for a WP site xD and you can confirm it's all working as it should? – treyBake Apr 26 '19 at 11:10
  • @treyBake I can confirm that it works as it should localy. btw we used bitnami to install wordpress on our machines, do you think that might affect the outcome? – Drohano Apr 26 '19 at 11:47
  • Did you try adding back slash in the front of the namespace or use path? – SaidbakR Apr 26 '19 at 11:53
  • @SaidbakR inc is a namespace and stands for ./includes – Drohano Apr 26 '19 at 11:57
  • We might have pinpointed the error, as someone commented in [link](https://stackoverflow.com/questions/46021003/composer-autoloader-working-in-local-but-not-in-server). We have not run Composer in the plugin directory on the live server. i'll update in a while if it works :D – Drohano Apr 26 '19 at 12:24

1 Answers1

0

I found the problem. Someone commented in this link.

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

xxx
  • 1,153
  • 1
  • 11
  • 23
Drohano
  • 47
  • 1
  • 6