I'm looking for routing theory vs a coding solution

Hello everyone. This question is for the CakePHP pros who understand the inner workings of routing.
I don’t want to post any code, but I do have a question for you.

Do you know how the platform uses the primary routes.php file as well as any supplied by any given plugin?
My app has 2 parts: a core and then features offered through plugins. The core uses the config/routes.php files, and my plugins use a routes.php file.

When I render a file found in a plugin through a controller in the core, I don’t get joy.

I’m looking for a coding / operational paradigm rather than specific ‘how to’.

Theories, man. I want theories. :slight_smile:

When you load plugins with the routes => true option, the router knows which plugins should have routes files loaded. In your application’s routes file you usually have a Plugin::routes() call which loads the routes. You can see that call in the app skeleton.

I’m not sure what theories you are looking for, could you explain that ask further?

Hi Mark;
Thanks for getting back.
I went back through the documentation on routing. I may need to construct some Route::connect() constructs.

I usually leave the default routing alone, as it does a good job. With the app I’m building now, I rely on ajax quite extensively. The plugin seems to render elements via ajax just fine. But when I render plugin elements from the core, I get a 500 HTTP error.

I’ll need to write in a specific route for the rendering path to file.

As far a theory goes, I was looking for an explanation for when a specific route pattern is applied. If my url context is a plugin, does Cake look for a route in Plugins/PluginName/routes.php to dispatch the request? If I’m not in a plugin, does cake use the config/routes.php file to dispatch the request?

Turns out, my error was a misplaced comma in the view file to be rendered.

I stripped the view file down to bare bones, and it showed up on the client. So I rebuilt each segment until I found the error.

I need coffee…

1 Like