2

Ok once again I'm having an issue with a plugin controller. It was working once upon a time but stopped sometime in the past year.

I have stripped the plugin down to bare, so there is no reason it shouldn't be working.

File Structure:

craft/plugins/
--webmentionreceiver/
----controllers/
------WebMentionReceiver_EndpointController.php
----WebMentionReceiverPlugin.php

craft/plugins/webmentionreceiver/controllers/WebMentionReceiver_EndpointController.php:

<?php
    namespace Craft;

    class WebMentionReceiver_EndpointController extends BaseController  {
                protected $allowAnonymous = array("actionReceive");

                public function actionReceive()  {
                        $this->redirect('/');
                }
        }
?>

So the plugin name is WebMentionReceiver, the controller is Endpoint and the action is Receive. So index.php?p=actions/webmentionreceiver/endpoint/receive should be the URL. But it 404s.

Any ideas? It is driving me mad!

  • 1
    Does camel casing the plugin name do anything so: 'webMentionReceiver' ? – Alec Ritson Sep 24 '15 at 20:16
  • Yes! That has worked. Thanks so much. Didn't realise the URL would be case sensitive. – Shane Hudson Sep 24 '15 at 20:33
  • @AlecRitson Could you post camel casing the URL as an answer please? Then I can choose it :) – Shane Hudson Sep 24 '15 at 21:00
  • No worries! Glad it helped, tried to give a bit more info in the answer :) – Alec Ritson Sep 24 '15 at 21:08
4

When your plugin has a camel cased name you need to make sure you camel case your references to it, such as when you try and visit an action url.

I assume this is due to when craft tries to resolve the url it sees pluginname and pluginName as two different things, much like php variables.

I would also assume this is due to the way Craft autoloads classes.

So using webMentionReciever would resolve since it would be a "exact" match to your plugin name.

This isn't limited to just plugin names, the same goes for any service, controller etc references too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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