XF 2.2 Create add-on for 2.2.16 but not shows for install

bahram40

Member
I have created this basic addon to test but when I upload it to the src/Addons folder, I can't see it in CPA to install it, and I have given 777 permission to all the folders.

Please could someone check the addon to see if there is something wrong.

Thx in advance.
 

Attachments

How does the directory look like?

I usually don’t download zip files from sketchy sources, lol. But you’re free to provide a screenshot.

Also 1.7kb seems very tiny to be an addon.
 
No problem here is the code.

src/
└── addons/
└── HolaMundo/
├── _data/
│ └── addon.json
├── Setup.php
├── XF/
│ ├── Pub/
│ │ └── Controller/
│ │ └── Hola.php
│ └── Template/
│ └── hola_mundo.html


addon.json.
{
"legacy_addon_id": "",
"title": "Hola Mundo",
"description": "Un addon que muestra 'Hola Mundo'.",
"version_id": 1000010,
"version_string": "1.0.0",
"dev": "TuNombre",
"dev_url": "https://tusitio.com",
"support_url": "https://tusitio.com/soporte",
"require": {
"XF": [2030000, "XenForo 2.3.0+"]
}
}

setup.php
<?php

namespace HolaMundo;

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

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

public function installStep1()
{
$this->createRoutePrefix();
}

public function uninstallStep1()
{
$this->deleteRoutePrefix();
}

public function upgrade(array $previousVersion, array &$stateChanges)
{
// Lógica de actualización
}

protected function createRoutePrefix()
{
$this->db()->insert('xf_route_prefix', [
'route_prefix' => 'hola',
'route_class' => 'HolaMundo\XF\Pub\Controller\Hola',
'context' => 'public',
'addon_id' => 'HolaMundo'
]);
}

protected function deleteRoutePrefix()
{
$this->db()->delete('xf_route_prefix', 'route_prefix = ?', 'hola');
}
}

Hola.php
<?php

namespace HolaMundo\XF\Pub\Controller;

use XF\Mvc\ParameterBag;
use XF\Pub\Controller\AbstractController;

class Hola extends AbstractController
{
public function actionIndex(ParameterBag $params)
{
$viewParams = [
'message' => 'Hola Mundo'
];
return $this->view('HolaMundo:Hola', 'hola_mundo', $viewParams);
}
}

hola_mundo.html

<h1>{$message}</h1>
 
I get this error on CLi when execute the command.

php cmd.php xf-addon:build-release src/addons/HolaMundo
No add-on with ID 'src/addons/HolaMundo' could be found.
In XF root / install

php cmd.php xf-addon:build-release Demo/Portal (Demo/ Portlal) should be ???directory???/ HolaMundo

Example:

1722284652468.webp

m1.webp

m2.webp
 
Last edited:
Back
Top Bottom