Skip to content

Generating Actions

Generate the actions of an ADR project with make:action.

ADR For ADR projects (see the flavor table in Overview).

make:action takes an HTTP method and a route path:

crest make:action GET /company/all
crest make:action GET /company/{id}

Crest does not have its own rule for the class name. It gets the name from the router of the framework (Router::classFor()). Each part of the path becomes a namespace part, and the class name is the HTTP method followed by these parts. Placeholders are not part of the name.

Command File
crest make:action GET /company/all src/Action/Company/All/GetCompanyAll.php
crest make:action GET /company/{id} src/Action/Company/GetCompany.php

Thus the file goes where the router looks for it. Route placeholders (the parts in braces, such as {id}) must come last: Crest stops on /album/{id}/edit, and tells you to write /album/edit/{id}.

--responder picks the responder that the action calls. The json responder gives a JSON response. The view responder renders a template with your renderer: the Renderer object of the project. For the other options, see make:action in the Command reference.

A view action names a template, but Crest does not create the template. Renderer::render() takes a name, not a path. Thus the folder and the extension belong to your renderer. Crest prints the name of the template, and does not guess a file name.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close