XF 2.1 Getting an error right off the bat with the Demo to learn how to make an Add-on

mark22

Member
I'm following the Add-on Demo: https://xenforo.com/xf2-docs/dev/lets-build-an-add-on/

When I try to run
Code:
php cmd.php xf-addon:install-step Demo/Portal 1

I get the following error:
Code:
PHP Fatal error:  Class Demo\Portal\Setup contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (XF\AddOn\AbstractSetup::install, XF\AddOn\AbstractSetup::upgrade, XF\AddOn\AbstractSetup::uninstall) in .../src/addons/Demo/Portal/Setup.php on line 22

This is my Setup.php file:
Code:
<?php

namespace Demo\Portal2;

use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;

use XF\Db\Schema\Alter;
use XF\Db\Schema\Create;

class Setup extends AbstractSetup
{
        use StepRunnerInstallTrait;
        use StepRunnerUpgradeTrait;
        use StepRunnerUninstallTrait;
}


class Setup extends \XF\AddOn\AbstractSetup
{

    public function installStep1()
    {
        $this->schemaManager()->alterTable('xf_forum', function(Alter $table)
        {
            $table->addColumn('demo_portal_auto_feature', 'tinyint')->setDefault(0);
        });
    }

public function installStep2()
{
    $this->schemaManager()->alterTable('xf_thread', function(Alter $table)
    {
        $table->addColumn('demo_portal_featured', 'tinyint')->setDefault(0);
    });
}


public function installStep3()
{
    $this->schemaManager()->createTable('xf_demo_portal_featured_thread', function(Create $table)
    {
        $table->addColumn('thread_id', 'int');
        $table->addColumn('featured_date', 'int');
        $table->addPrimaryKey('thread_id');
    });
}


}

I'm sure this is some amazingly stupid mistake?
 
You have two classes declared in your PHP.

The public functions should all be right after use StepRunnerUninstallTrait; in first setup class. And the second setup class should not exist at all.
 
Top Bottom