Create a page for testing C5 api or manual task
Permalink
Hi,
When developing with C5, I usually need a page to test c5 API, get data from other databases etc. For creating this page, I put a bare page template in my active theme, then create a page type and template, and finally create a page in the C5 sitemap, that use that template file. Then I start writing code and testing them.
I recently wondered if there is a simpler way to create a page directly, somewhere in the C5 application folder, for example, that can be used for this purpose without creating any page type, or a single page, anything directly executable via the browser?
When developing with C5, I usually need a page to test c5 API, get data from other databases etc. For creating this page, I put a bare page template in my active theme, then create a page type and template, and finally create a page in the C5 sitemap, that use that template file. Then I start writing code and testing them.
I recently wondered if there is a simpler way to create a page directly, somewhere in the C5 application folder, for example, that can be used for this purpose without creating any page type, or a single page, anything directly executable via the browser?
I'm not sure if it would be easier or not but you could create a simple package with just a route in it to a file with whatever you need to execute happening in the class' method that the route points to.
You can create a custom route, e.g. via:
You'd normally add this to the on_start method of package controller.
$router = $this->app->make(RouterInterface::class); $router->registerMultiple([ '/your-api' => [ '\Your\Package\Controller\Api::view', ], ]);
You'd normally add this to the on_start method of package controller.
you can test all that in application/bootstrap/app.php. You even have several examples in the file itself