# |
Jan 7th 2020, 16:43 |
ndm |
use a slash only `/` |
# |
Jan 7th 2020, 16:43 |
damiano |
the route still works with test.localhost/webhook/ <-- |
# |
Jan 7th 2020, 16:43 |
damiano |
the problem is that if i remove the 'path' |
# |
Jan 7th 2020, 16:42 |
damiano |
$routes->plugin( 'Webhook', ['path' => '/webhook',], <---- i need to remove this |
# |
Jan 7th 2020, 16:42 |
damiano |
@ndm last thing... |
# |
Jan 7th 2020, 16:42 |
damiano |
@ndm you are right :) |
# |
Jan 7th 2020, 16:41 |
damiano |
if i do foo3.localhost/webhook/my-controller/action works too and so on... |
# |
Jan 7th 2020, 16:41 |
ndm |
You probably still have the fallbacks connected |
# |
Jan 7th 2020, 16:41 |
damiano |
if i do foo2.localhost/webhook/my-controller/action works too |
# |
Jan 7th 2020, 16:41 |
damiano |
if i do foo1.localhost/webhook/my-controller/action works |
# |
Jan 7th 2020, 16:40 |
damiano |
@ndm strange thing happen....i can reach the controller but i can use whatever subdomain i want |
# |
Jan 7th 2020, 16:37 |
damiano |
let me check |
# |
Jan 7th 2020, 16:37 |
damiano |
ok |
# |
Jan 7th 2020, 16:36 |
damiano |
in my Application.php there is $this->addPlugin('Webhook'); |
# |
Jan 7th 2020, 16:36 |
ndm |
It would be `test.localhost/webhook/...` |
# |
Jan 7th 2020, 16:36 |
damiano |
if i do test.localhost i always see the pages/home.ctp |
# |
Jan 7th 2020, 16:35 |
damiano |
@ndm by the wway when i run the local server bin/cake server i cannot reach that controller |
# |
Jan 7th 2020, 16:35 |
ndm |
I wouldn't necessarily call it a bug, more like a missing feature. Thing is, `_method` for example is set in the routing defaults, while `_host` is an option. |
# |
Jan 7th 2020, 16:30 |
damiano |
@ndm do you mean bin/cake routes has a bug (maybe) ? |
# |
Jan 7th 2020, 16:29 |
ndm |
I'm not sure why that is, maybe `_host` is somewhat special, or it's missing by accident |
# |
Jan 7th 2020, 16:25 |
slackebot |
{"action":"index","plugin":"Webhook"} |
# |
Jan 7th 2020, 16:25 |
damiano |
webhook._controller:_action | /webhook/{controller}/{action}/* | {"action":"index","plugin":"Webhook"} | | webhook._controller:index | /webhook/{controller} | {"action":"index","plugin":"Webhook"} | | webhook._controller:_action | /webhook/{controller}/{action}/* | |
# |
Jan 7th 2020, 16:25 |
damiano |
i see |
# |
Jan 7th 2020, 16:25 |
damiano |
yes you are right however i cannot see the HOST if i do bin/cake routes |
# |
Jan 7th 2020, 16:24 |
ndm |
That should work, but the fallbacks will not be bound to a host |
# |
Jan 7th 2020, 16:23 |
damiano |
yes because in that plugin i have many controllers |
# |
Jan 7th 2020, 16:23 |
damiano |
public function routes(RouteBuilder $routes): void { $routes->plugin( 'Webhook', [], function (RouteBuilder $builder) { // Add custom routes here $builder->connect('/{controller}/{action}/*', [])->setHost('test.localhost'); $builder->fallbacks(); } ); parent::routes($routes); } |
# |
Jan 7th 2020, 16:23 |
ndm |
assuming you actually want to create plugin routes |
# |
Jan 7th 2020, 16:23 |
ndm |
inside of the callable, yes |
# |
Jan 7th 2020, 16:22 |
damiano |
ndm so basically i can put something like $routes->connect('/{controller}/{action}')->setHost('foo.example.com') ? |
# |
Jan 7th 2020, 16:20 |
ndm |
You provide a callback in which you connect the plugin routes via `connect()`, and there you can either use the `_host` option, or the `setHost()` method. https://book.cakephp.org/4/en/development/routing.html#plugin-routing |
# |
Jan 7th 2020, 16:17 |
damiano |
@ndm how can i set the host in $routes->plugin() ? |
# |
Jan 7th 2020, 16:10 |
ndm |
I fail to see the problem, you can generally set the host on any route you want |
# |
Jan 7th 2020, 16:09 |
damiano |
anyone? |
# |
Jan 7th 2020, 15:51 |
damiano |
how can i do that? should i add a ->connect()and then ->setHost() ? sounds verbose because {controller}/{action} is the default route |
# |
Jan 7th 2020, 15:50 |
damiano |
i know i can use setHost() but i busically have webhook.domain.com/{controller}/{action} |
# |
Jan 7th 2020, 15:50 |
damiano |
hey guys i have seen that cake 4.x has moved the plugin routes inside PLugin.php is it possible to set the _host in the $routes->plugin(..) ? |
# |
Jan 7th 2020, 15:39 |
ricksaccous |
i'm not sure |
# |
Jan 7th 2020, 15:39 |
ricksaccous |
I think list just kind of autocombines, but combine does it at the result level and list does it at the query level... |
# |
Jan 7th 2020, 15:37 |
val |
in 3.x what is the difference between `$this->MyModel->find()->combine(...)` and `$this->MyModel->find('list')->`? It looks that both return the same results, don't they? |
# |
Jan 7th 2020, 15:32 |
ricksaccous |
hohoho |