hemant_bhardwaj
Well-known member
well I were following everything but still, it's not installing - https://xenforo.com/xf2-docs/dev/lets-build-an-add-on/#creating-the-setup-class
# php cmd.php xf-addon:install-step Demo/portal 1
Running Setup class method installStep1()...
An exception occurred: [TypeError] Argument 1 passed to Demo\Portal\Setup:emo\Portal\{closure}() must be an instance of Demo\Portal\Alter, instance of XF\Db\Schema\Alter given, called in C:\xampp\htdocs\xenforo\src\XF\Db\SchemaManager.php on line 142 in src\addons\Demo\Portal\Setup.php on line 18
#0 src\XF\Db\SchemaManager.php(142): Demo\Portal\Setup->Demo\Portal\{closure}(Object(XF\Db\Schema\Alter))
#1 src\addons\Demo\Portal\Setup.php(21): XF\Db\SchemaManager->alterTable('xf_forum', Object(Closure))
#2 src\XF\Cli\Command\AddOn\AbstractSetupStep.php(128): Demo\Portal\Setup->installStep1(Array)
#3 src\XF\Cli\Command\AddOn\AbstractSetupStep.php(68): XF\Cli\Command\AddOn\AbstractSetupStep->runStep(Object(Demo\Portal\Setup), Object(Symfony\Component\Console\Output\ConsoleOutput), 'install', '1', NULL, Array)
#4 src\vendor\symfony\console\Command\Command.php(242): XF\Cli\Command\AddOn\AbstractSetupStep->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 src\vendor\symfony\console\Application.php(843): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 src\vendor\symfony\console\Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(XF\Cli\Command\AddOn\InstallStep), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 src\vendor\symfony\console\Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 src\XF\Cli\Runner.php(63): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 cmd.php(15): XF\Cli\Runner->run()
#10 {main}
setup file -
# php cmd.php xf-addon:install-step Demo/portal 1
Running Setup class method installStep1()...
An exception occurred: [TypeError] Argument 1 passed to Demo\Portal\Setup:emo\Portal\{closure}() must be an instance of Demo\Portal\Alter, instance of XF\Db\Schema\Alter given, called in C:\xampp\htdocs\xenforo\src\XF\Db\SchemaManager.php on line 142 in src\addons\Demo\Portal\Setup.php on line 18
#0 src\XF\Db\SchemaManager.php(142): Demo\Portal\Setup->Demo\Portal\{closure}(Object(XF\Db\Schema\Alter))
#1 src\addons\Demo\Portal\Setup.php(21): XF\Db\SchemaManager->alterTable('xf_forum', Object(Closure))
#2 src\XF\Cli\Command\AddOn\AbstractSetupStep.php(128): Demo\Portal\Setup->installStep1(Array)
#3 src\XF\Cli\Command\AddOn\AbstractSetupStep.php(68): XF\Cli\Command\AddOn\AbstractSetupStep->runStep(Object(Demo\Portal\Setup), Object(Symfony\Component\Console\Output\ConsoleOutput), 'install', '1', NULL, Array)
#4 src\vendor\symfony\console\Command\Command.php(242): XF\Cli\Command\AddOn\AbstractSetupStep->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 src\vendor\symfony\console\Application.php(843): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 src\vendor\symfony\console\Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(XF\Cli\Command\AddOn\InstallStep), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 src\vendor\symfony\console\Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 src\XF\Cli\Runner.php(63): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 cmd.php(15): XF\Cli\Runner->run()
#10 {main}
setup file -
Code:
<?php
namespace Demo\Portal;
use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;
class Setup extends AbstractSetup
{
use StepRunnerInstallTrait;
use StepRunnerUpgradeTrait;
use StepRunnerUninstallTrait;
public function installStep1()
{
$this->schemaManager()->alterTable('xf_forum', function(Alter $table)
{
$table->addColumn('demo_portal_auto_feature', 'tinyint')->setDefault(0);
});
}
}