Skip to content

Folder Structure

Every API resource is the same five files plus lang and tests. Each has one job.

The Model declares the endpoints. Reads go through a Provider, writes through a Processor, and both hit the core repository:

lang strings and the two test files hang off each resource — see the table below.

UnitPath shapeResponsibility
Modelsrc/*/Models/*.php#[ApiResource] — declares REST + GraphQL operations and the OpenAPI block
DTOsrc/*/Dto/*Input.phpTyped input contract (validation surface + GraphQL input type)
Providersrc/*/State/*Provider.phpRead path: auth, query, response envelope
Processorsrc/*/State/*Processor.phpWrite path: validation, core repo call, events, permission gate
Resolversrc/*/Resolver/*.phpGraphQL custom query resolver (only when needed)
langResources/lang/en/app.phpAll user-facing strings (single-file convention)
teststests/Feature/{RestApi,GraphQL}/*Test.phpLock both transports

Shop resources live under src/{Models,Dto,State}. New collection/item providers extend the shared abstract base providers — reuse, don't re-scaffold.

Admin resources are different

Admin uses the same file roles, but everything lives under src/Admin/** and every class is prefixed Admin (e.g. AdminAttributeProcessor). Two differences to know:

The read path is split into two providers, not one:

FilePath shapeJob
Collection providersrc/Admin/State/Admin*CollectionProvider.phpList (filter, sort, paginate)
Item providersrc/Admin/State/Admin*ItemProvider.phpSingle record read
Processorsrc/Admin/State/Admin*Processor.phpWrite (create / update)
Mass-delete processorsrc/Admin/State/Admin*MassDeleteProcessor.phpBulk delete

Admin has extra folders shop doesn't:

  • src/Admin/Rules/ — validation rule classes (shop keeps these in src/Validators/).
  • src/Admin/DataGrids/ — list filter/sort/pagination definitions backing the collection providers.

Keep the shop and admin trees separate.

Released under the MIT License.