PHPackages                             csoellinger/silverstripe-model-annotations-task - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. csoellinger/silverstripe-model-annotations-task

ActiveSilverstripe-vendormodule[Database &amp; ORM](/categories/database)

csoellinger/silverstripe-model-annotations-task
===============================================

A SilverStripe Task to generate data object model annotations for defined db fields including fields defined in extensions.

v1.0.1(4y ago)3221BSD-3-ClausePHPPHP &gt;=7.4,&lt;8.1CI failing

Since Apr 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/CSoellinger/silverstripe-model-annotations-task)[ Packagist](https://packagist.org/packages/csoellinger/silverstripe-model-annotations-task)[ Docs](https://github.com/CSoellinger/silverstripe-model-annotations-task)[ RSS](/packages/csoellinger-silverstripe-model-annotations-task/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (15)Versions (3)Used By (0)

SilverStripe Model Annotations Task
===================================

[](#silverstripe-model-annotations-task)

[![Build Status](https://camo.githubusercontent.com/b8a800640f9cde15c9941d33af25d0a821a079276d87bf2215d382640e43f23d/68747470733a2f2f6170702e7472617669732d63692e636f6d2f43536f656c6c696e6765722f73696c7665727374726970652d6d6f64656c2d616e6e6f746174696f6e732d7461736b2e7376673f6272616e63683d6d61696e)](https://app.travis-ci.com/CSoellinger/silverstripe-model-annotations-task)[![codecov](https://camo.githubusercontent.com/d165fae3c5591e395e749e04b12bc1c92a49be55f376321619a9e91061c5a062/68747470733a2f2f636f6465636f762e696f2f67682f43536f656c6c696e6765722f73696c7665727374726970652d6d6f64656c2d616e6e6f746174696f6e732d7461736b2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d38473737324b5a4f3338)](https://codecov.io/gh/CSoellinger/silverstripe-model-annotations-task)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/58e5df8318863136cd5488c4aa1c2c1f15f52cbf6d523d8dfa4a753674b126b3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f43536f656c6c696e6765722f73696c7665727374726970652d6d6f64656c2d616e6e6f746174696f6e732d7461736b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/CSoellinger/silverstripe-model-annotations-task/?branch=main)

This module adds a dev task which generates annotations for your data object models. The problem is if you are working a lot with silver stripe models you will learn that no IDE can handle the DB fields as properties and/or collections as methods. So i made this task which completes my models with annotations from existing configs of the model itself and all extensions of it. Configs handled: db, has\_one, has\_many, many\_many, many\_many(through), belongs\_to, belongs\_many\_many.

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)
    1. [Web](#web)
    2. [Terminal](#terminal)
    3. [Optional params](#optional-params)
4. [Options](#options)
    1. [dryRun (default: true)](#dryrun-default-true)
    2. [quiet (default: false)](#quiet-default-false)
    3. [createBackupFile (default: false)](#createbackupfile-default-false)
    4. [addUseStatements (default: false)](#addusestatements-default-false)
5. [Example](#example)
6. [Documentation](#documentation)
7. [License](#license)
8. [Maintainers](#maintainers)
9. [Bugtracker](#bugtracker)
10. [Development and contribution](#development-and-contribution)

Requirements
------------

[](#requirements)

- PHP 7.4 - PHP 8.0
- PHP-AST extension
- PHP-BCMATH extension
- SilverStripe ^4.10

Installation
------------

[](#installation)

```
composer require --dev csoellinger/silverstripe-model-annotations-task

```

Usage
-----

[](#usage)

Run dev build to load the task and after you can execute it in your browser or cli.

### Web

[](#web)

```
http://localhost/tasks/ModelAnnotationsTask

```

### Terminal

[](#terminal)

```
vendor/bin/sake dev/tasks/ModelAnnotationsTask
```

### Optional params

[](#optional-params)

- dryRun=0/1
- quiet=0/1
- createBackupFile=0/1
- addUseStatements=0/1

Take a look at options section below to get more information about the params.

Options
-------

[](#options)

All optional params from above can be set as silverstripe config at the ModelAnnotationsTask. Only difference is that the config is set as boolean var and not as integer. By default dryRun is set to true. If you want write the files with this task you need to set the config or set the param to false.

### dryRun (default: true)

[](#dryrun-default-true)

Only print the changes inside your browser or terminal and don't write any file.

### quiet (default: false)

[](#quiet-default-false)

No output.

### createBackupFile (default: false)

[](#createbackupfile-default-false)

Create a backup file before writing the model. Only if dryRun is false.

### addUseStatements (default: false)

[](#addusestatements-default-false)

Collect data types which are not declared as use statement and add them to the file. If this config is true it also shortens the data types.

Example
-------

[](#example)

Here you see a small example how it will look your model file after using the task.

Your Input

```
