I'm a total Craft newbie, so I hope this question isn't ridiculous.

I just want to see a controller / action work in my new module.

I have src/controllers/ScrapeController.php as such:

<?php

namespace mycompany\mymodule\controllers;

use craft\web\Controller;

class ScrapeController extends Controller {

    public function actionPush()
    {
        return $this->asJson([
            'success' => TRUE,
        ]);
    }
}

And I just want to see this URL work: http://localhost/my-module/scrape/push

But instead I get: HTTP 404 - Template not found

I'm sure I'm missing something really dumb here. Any ideas?

up vote 2 down vote accepted

You'll either need to use the action url http://localhost/actions/my-module/scrape/push since only those will route to controllers by default or create a custom route to your controller

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.