Neuron-PHP

ResourceScaffolder

Generates the field-aware CRUD stack (model, DTO, repository, controller, views) from a resolved resource {@see $info} array and a {@see FieldSet}.

The placeholder template engine only performs flat string substitution, so all per-field code/markup is pre-rendered here and injected as placeholder values.

Table of Contents

Properties

$fs  : IFileSystem
$projectPath  : string
$templates  : ITemplateEngine

Methods

__construct()  : mixed
generateController()  : string
Generate the controller file.
generateDto()  : string
Generate the DTO YAML definition under resources/dtos.
generateModel()  : string
Generate the Neuron ORM model.
generateRepository()  : array<string|int, string>
Generate the repository interface and database implementation.
generateViews()  : array<string|int, string>
Generate the field-aware HTML views (index, create, edit, show, _form).
buildDtoBody()  : string
Build the DTO YAML property body.
buildFormFields()  : string
Build the form field markup for create/edit.
buildIndexCells()  : string
Build the <td> cells for the index table, referencing the loop variable.
buildIndexHeaders()  : string
Build the <th> cells for the index table.
buildModelAccessors()  : string
Build fluent getters/setters for the model.
buildModelFromArray()  : string
Build the body of fromArray().
buildModelProperties()  : string
Build typed, defaulted property declarations for the model.
buildModelToArray()  : string
Build the non-primary entries of toArray().
buildModelToArrayPrimary()  : string
Build the conditional inclusion of the primary key in toArray().
buildShowRows()  : string
Build the definition rows for the show view.
controllerNamespace()  : string
The fully qualified controller namespace (base + sub-namespace).
guardExisting()  : void
Throw if the target exists and overwrite was not requested.
namespaceToDir()  : string
Map a PHP namespace to a project-relative directory, treating the leading "App\" segment as the conventional "app/" directory.
put()  : void
Ensure a directory exists then write a file, throwing on failure.

Properties

Methods

generateController()

Generate the controller file.

public generateController(array<string|int, mixed> $info[, bool $force = false ]) : string
Parameters
$info : array<string|int, mixed>
$force : bool = false
Return values
string

Path to the created file

generateDto()

Generate the DTO YAML definition under resources/dtos.

public generateDto(array<string|int, mixed> $info, FieldSet $fields[, bool $force = false ]) : string
Parameters
$info : array<string|int, mixed>
$fields : FieldSet
$force : bool = false
Return values
string

Path to the created file

generateModel()

Generate the Neuron ORM model.

public generateModel(array<string|int, mixed> $info, FieldSet $fields[, bool $force = false ]) : string
Parameters
$info : array<string|int, mixed>
$fields : FieldSet
$force : bool = false
Return values
string

Path to the created file

generateRepository()

Generate the repository interface and database implementation.

public generateRepository(array<string|int, mixed> $info[, bool $force = false ]) : array<string|int, string>
Parameters
$info : array<string|int, mixed>
$force : bool = false
Return values
array<string|int, string>

Paths to the created files

generateViews()

Generate the field-aware HTML views (index, create, edit, show, _form).

public generateViews(array<string|int, mixed> $info, FieldSet $fields[, bool $force = false ]) : array<string|int, string>
Parameters
$info : array<string|int, mixed>
$fields : FieldSet
$force : bool = false
Return values
array<string|int, string>

Paths to the created files

buildFormFields()

Build the form field markup for create/edit.

private buildFormFields(FieldSet $fields) : string
Parameters
$fields : FieldSet
Return values
string

buildIndexCells()

Build the <td> cells for the index table, referencing the loop variable.

private buildIndexCells(FieldSet $fields, array<string|int, mixed> $info) : string
Parameters
$fields : FieldSet
$info : array<string|int, mixed>
Return values
string

buildIndexHeaders()

Build the <th> cells for the index table.

private buildIndexHeaders(FieldSet $fields) : string
Parameters
$fields : FieldSet
Return values
string

buildModelAccessors()

Build fluent getters/setters for the model.

private buildModelAccessors(FieldSet $fields) : string
Parameters
$fields : FieldSet
Return values
string

buildModelFromArray()

Build the body of fromArray().

private buildModelFromArray(FieldSet $fields) : string
Parameters
$fields : FieldSet
Return values
string

buildModelProperties()

Build typed, defaulted property declarations for the model.

private buildModelProperties(FieldSet $fields) : string
Parameters
$fields : FieldSet
Return values
string

buildModelToArray()

Build the non-primary entries of toArray().

private buildModelToArray(FieldSet $fields) : string
Parameters
$fields : FieldSet
Return values
string

buildModelToArrayPrimary()

Build the conditional inclusion of the primary key in toArray().

private buildModelToArrayPrimary(FieldSet $fields) : string
Parameters
$fields : FieldSet
Return values
string

buildShowRows()

Build the definition rows for the show view.

private buildShowRows(FieldSet $fields, array<string|int, mixed> $info) : string
Parameters
$fields : FieldSet
$info : array<string|int, mixed>
Return values
string

controllerNamespace()

The fully qualified controller namespace (base + sub-namespace).

private controllerNamespace(array<string|int, mixed> $info) : string
Parameters
$info : array<string|int, mixed>
Return values
string

guardExisting()

Throw if the target exists and overwrite was not requested.

private guardExisting(string $file, bool $force, string $label) : void
Parameters
$file : string
$force : bool
$label : string

namespaceToDir()

Map a PHP namespace to a project-relative directory, treating the leading "App\" segment as the conventional "app/" directory.

private namespaceToDir(string $namespace) : string
Parameters
$namespace : string
Return values
string

put()

Ensure a directory exists then write a file, throwing on failure.

private put(string $dir, string $file, string $content) : void
Parameters
$dir : string
$file : string
$content : string
On this page

Search results