1.2.1. Usage

You can write your persistence model classes by hand, but it's going to be
tedious to do so. Instead, use the ./vendor/bin/atlas-skeleton command to read
the table information from the database and generate them for you.

1.2.1.1. Configure Connection

First, create a PHP file to return an array of configuration parameters for
skeleton generation. Provide an array of PDO connection arguments, a string for
the namespace prefix, and a directory to write the classes to:

Most of these classes will be empty, and are provided so you can extend their
behavior if you wish. They also serve to assist IDEs with autocompletion of
return typehints.

Warning:

If you run the skeleton generator more than once, the following classes will
be OVERWRITTEN and you will lose any changes to them:

{TYPE}Fields.php

{TYPE}Row.php

{TYPE}Table.php

The remaining classes will remain untouched.

1.2.1.3. Custom Transformations

If you are unsatisfied with how the skeleton generator transforms table names to
persistence model type names, you can instantiate the Transform class in the
config file under the transform key, and pass an array of table-to-type names
to override the default transformations:

1.2.1.4. Custom Templates

You can override the templates used by the skeleton generator and provide your
own instead. This lets you customize the code generation; for example, to add
your own common methods or to extend intercessory classes.

First, take a look at the default templates in the Atlas.Cli resources/templates/
directory:

Type.tpl

TypeEvents.tpl

TypeFields.tpl

TypeRecord.tpl

TypeRecordSet.tpl

TypeRelationships.tpl

TypeRow.tpl

TypeSelect.tpl

TypeTable.tpl

TypeTableEvents.tpl

TypeTableSelect.tpl

For each persistence model type name, the word "Type" in the filename will be
replaced with the type; .tpl will be replaced with .php. For example, a
threads table will become a Thread type, so the resulting files will be
Thread.php, ThreadEvents.php, and so on.

To override a default template, create a custom template file of the same name
in a directory of your own choosing. Then, in the skeleton config file, set
a 'templates' key to that directory: