1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Callback class::method is invalid -> Error while createing new addon

Discussion in 'XenForo Development Discussions' started by TheBigK, Nov 13, 2014.

  1. TheBigK

    TheBigK Well-Known Member

    I'm following furrman's tutorial:- https://xenforo.com/community/resources/how-to-read-and-write-into-the-database-with-a-page.328/

    I've created file/folder structure as follows:-

    library / SimpleText / Installer.php

    Installer.php code:-
    PHP:
    <?php

    class SimpleText_Installer
    {
        
    //Creating required tables in the database

        // $table = array('createQuery', 'dropQuery')

        
    protected static $table = array(
            
    'createQuery' => 'CREATE TABLE IF NOT EXISTS `xf_simple_text` (
                    `simple_id` INT( 10 ) NOT NULL AUTO_INCREMENT,
                    `simple_text` VARCHAR ( 200 ),
                    `simple_date` INT( 10 ) UNSIGNED,
                    PRIMARY KEY (`simple_id`)
                    )
                ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;'
    ,
            
    'dropQuery' => 'DROP TABLE IF EXISTS `xf_simple_text`'
        
    );

        public static function 
    install()
        {
            
    $db XenForo_Application::get('db');
            
    $db->query(self::$table['createQuery']);
        }

        public static function 
    uninstall()
        {
            
    $db XenForo_Application::get('db');
            
    $db->query(self::$table['dropQuery']);
        }

    }
    I saved the file, then went to admin control panel and created a new addon with following Information:-

    Add-on ID: SimpleTextAddon
    Title: Simple Text Add On
    Version String: 1.0
    Version ID: 1
    Installation Code: SimpleText_Installer :: install
    Uninstallation Code: SimpleText_Installer::uninstall

    When I click 'Save Addon', I'm getting an error in overlay that says -

    I'm unable to figure out why is the system not accepting my class::method. Can someone tell me what's missing or wrong?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Everything you have typed above looks correct, so my only assumption is that something must be typed different to how it it above.

    e.g are you sure the folder where the PHP is is actually called SimpleText? Rather than simpletext? Or Simpletext? Are you sure it's spelt correctly?

    Same goes with the file name. It will be case sensitive.
     
  3. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    hmm... I also don't see any error here...
     
  4. TheBigK

    TheBigK Well-Known Member

    Bang on! My 'SimpleText' folder was at the same level as 'library'. Damn, I gotta get used to this new IDE. I moved SimpleText under library and it worked.

    Should have be more careful.
     
    Insy and Chris D like this.

Share This Page