Before I get tagged as a duplicate I have already tried everything in the 'duplicate' issues on here to no avail so I'm posting my exact config to see what I'm doing wrong.
Here is my plugin code and my controller code
// My plugin and init funciton
use belniakmedia\sitedominjector\controllers\DefaultController;
class SiteDomInjector extends Plugin
{
/**
* @var SiteDomInjector
*/
public static $plugin;
/** @var array */
public $controllerMap = [
'default' => DefaultController::class,
];
public function init()
{
parent::init();
self::$plugin = $this;
// Register our site routes
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_SITE_URL_RULES,
function (RegisterUrlRulesEvent $event) {
$event->rules['echo'] = 'site-dom-injector/default/index';
}
);
}
}
// My Controller
class DefaultController extends Controller
{
protected $allowAnonymous = true;
public function actionIndex()
{
$result = 'Welcome to the DefaultController actionIndex() method';
return $result;
}
}
I really don't know if that controller map is necessary or not but one of the posts on here said they got it to work setting that up, so thats what I did.
Here is a photo of my plugin's file structure for continuity:
I really have no idea why this isnt working but no matter what I do, when I try to browse to http://site.local/echo I get a 404 not found and the trace seems like its not even attempting to load the controller and is just looking for a matching template file... :(
Any ideas?
site-dom-injector/default
when I create your plugin with Pluginfactory.io the default output is$event->rules['siteActionTrigger1'] = 'site-dom-injector/default-controller';
so - I could be totally wrong - but maybe the controller will only route to Index if you don't declare anything – Robin Schambach Nov 17 '17 at 6:49