{"id":1159,"date":"2022-09-15T19:40:50","date_gmt":"2022-09-15T18:40:50","guid":{"rendered":"https:\/\/editjournal.redakt.eu\/faxmodem\/?p=1159"},"modified":"2023-03-01T08:54:19","modified_gmt":"2023-03-01T08:54:19","slug":"plugin-none-connected-routes-match-provided-parameters","status":"publish","type":"post","link":"https:\/\/editjournal.redakt.eu\/faxmodem\/blog\/development\/cakephp\/plugin-none-connected-routes-match-provided-parameters\/","title":{"rendered":"CakePHP plugin: None of the currently connected routes match the provided parameters"},"content":{"rendered":"<p>If you want your plugin to have and use routes, you need to configure it first - otherwise,<\/p>\n<blockquote>\n<p>None of the currently connected routes match the provided parameters. Add a matching route to config\/routes.php<\/p>\n<\/blockquote>\n<p>Start by enabling routes and bootstrapping when you load the plugin in your <code>src\/Application.php<\/code>:<\/p>\n<pre><code>$this->addPlugin('MyPlugin', ['bootstrap' => true, 'routes' => true]);<\/code><\/pre>\n<p>Create <code>plugins\/MyPlugin\/config\/routes.php<\/code> with the following content:<\/p>\n<pre><code>&lt;?php\nuse Cake\\Routing\\RouteBuilder;\nuse Cake\\Routing\\Route\\DashedRoute;\nuse Cake\\Routing\\Router;\n\nRouter::plugin($this-&gt;getName(), function (RouteBuilder $routes) {\n    $routes-&gt;fallbacks(DashedRoute::class);\n});<\/code><\/pre>\n<p>Make sure to load the above config in the plugin's <code>plugins\/MyPlugin\/config\/bootstrap.php<\/code>:<\/p>\n<pre><code>&lt;?php\n\nuse Cake\\Core\\Plugin as CorePlugin;\n\nif (CorePlugin::getCollection()-&gt;get($this-&gt;getName())-&gt;isEnabled(&#039;routes&#039;)) {\n    include dirname(__FILE__) . DIRECTORY_SEPARATOR . &#039;routes.php&#039;;\n}<\/code><\/pre>\n<p>The routing inside your plugin should be working now:<\/p>\n<pre><code>\\Cake\\Routing\\Router::url([\n    &#039;prefix&#039; =&gt; false,\n    &#039;plugin&#039; =&gt; &#039;MyPlugin&#039;,\n    &#039;controller&#039; =&gt; &#039;Users&#039;,\n    &#039;action&#039; =&gt; &#039;login&#039;,\n]),<\/code><\/pre>\n<p>The above uses <code>$this-&gt;getName()<\/code> to fetch the current plugin name instead of hardcoding <code>MyPlugin<\/code>, but you can do that instead if you prefer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want your plugin to have and use routes, you need to configure it first &#8211; otherwise, None of the currently connected routes match the provided parameters. Add a matching route to config\/routes.php Start by enabling routes and bootstrapping when you load the plugin in your src\/Application.php: $this->addPlugin(&#8216;MyPlugin&#8217;, [&#8216;bootstrap&#8217; => true, &#8216;routes&#8217; => true]);&hellip; <a class=\"more-link\" href=\"https:\/\/editjournal.redakt.eu\/faxmodem\/blog\/development\/cakephp\/plugin-none-connected-routes-match-provided-parameters\/\">Continue reading <span class=\"screen-reader-text\">CakePHP plugin: None of the currently connected routes match the provided parameters<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1047],"tags":[715,1050],"class_list":["post-1159","post","type-post","status-publish","format-standard","hentry","category-cakephp","tag-cakephp","tag-cakephp-plugin-development","entry"],"_links":{"self":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/comments?post=1159"}],"version-history":[{"count":4,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1159\/revisions"}],"predecessor-version":[{"id":1164,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1159\/revisions\/1164"}],"wp:attachment":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/media?parent=1159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/categories?post=1159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/tags?post=1159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}