PHPackages                             layla/cody - 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. layla/cody

ActiveLibrary

layla/cody
==========

0.2.1(12y ago)523MITPHP

Since Mar 24Pushed 12y ago2 watchersCompare

[ Source](https://github.com/layla/cody)[ Packagist](https://packagist.org/packages/layla/cody)[ RSS](/packages/layla-cody/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (10)Versions (6)Used By (0)

Cody
====

[](#cody)

Cody is a code generator that generates objects and resources for different languages and frameworks. Cody utilises a very simple configuration format for defining your objects and resources.

The input format
================

[](#the-input-format)

The input format for the generator is as following (example is given in yaml, other formats are supported too)

The root
--------

[](#the-root)

The root of the input contains the package name the resources that exist within in the package.

```
package: Vendor.Name
resources:
  __RESOURCES__
```

PropertyDescription`package`Contains the vendor and name of the page, seperated with a `.` and capitalized.
The reason we capitalize the vendor and name is because this way, it will contain more information for our compilers.
Compilers will use the Package name in filenames and namespaces, this may differ per compiler.`resources`Determines the [resources](#resources) that are present in the package

Resources
---------

[](#resources)

The resources are defined with the names as the key, and the configurations as the value

PropertyDescriptionnameThe name property indicates the name as the key, and the [resource configuration](#resource-configuration) as valueAn example:

```
Models.User:
  __RESOURCE_CONFIGURATION__
Models.NewsItem
  __RESOURCE_CONFIGURATION__
```

Resource Configuration
----------------------

[](#resource-configuration)

The resource configuration may only contain 2 keys. The compilers key should always be present, it tells Cody what compiler(s) it should use to compile your resource. The second key can be one of the following:

KeyTypeDescription`compilers`arrayIndicates what compilers should be used to compile the resource, available options are:
**php-core**
**php-laravel**
**js-core**
**js-ember**`class`[class configuration](#class-configuration)Indicates the resource is of type Class, value of this key is the configuration for the class`model`[model configuration](#model-configuration)Indicates the resource is of type Model, value of this key is the configuration for the model`controller`[controller configuration](#controller-configuration)Indicates the resource is of type Controller, value of this key is the configuration for the controllerThe compiler expects the resource to ONLY contain the `compilers` property and on of the available types.

An example:

```
Models.User:
  class:
    __CLASS_CONFIGURATION__
  compilers:
    - php-laravel
```

Class configuration
-------------------

[](#class-configuration)

The class configuration holds all the information we need to build a class. The available options are

KeyTypeDescription`base`stringIndicates the base class of this class`properties`[property configuration](#property-configuration)Keys represent the name of the property, values contain the [property configuration](#property-configuration)`methods`[method configuration](#method-configuration)Keys represent the method name, values contain the [method configuration](#method-configuration)```
base: MyApp.Foundation.Models.Base
properties:
  rules:
    __PROPERTY_CONFIGURATION__
methods:
  get.rules:
    __METHOD_CONFIGURATION__
  set.rules
    __METHOD_CONFIGURATION__
```

Model configuration
-------------------

[](#model-configuration)

A model is an extension of the class, it allows you to specify relations and columns, and will automatically add the necesarry methods / properties for you, depending on the compiler.

KeyTypeDescription`base`stringIndicates the base class of this class`properties`[property configuration](#property-configuration)Indicates the properties that should be present on the class`methods`[method configuration](#method-configuration)Indicates the methods that should be present on the class`relations`[relation configuration](#relation-configuration)Indicates the relations that should be present on the model`columns`[column configuration](#column-configuration)Indicates the columns that should be present on the model```
base: MyApp.Foundation.Models.Base
properties:
  rules:
    __property_configuration
methods:
  get.rules:
    __METHOD_CONFIGURATION__
  set.rules
    __METHOD_CONFIGURATION__
relations:
  __RELATION_CONFIGURATION__
columns:
  __COLUMN_CONFIGURATION__
```

Method configuration
--------------------

[](#method-configuration)

A method can be added to class resources, or subclasses thereof (models, controllers, etc.)

KeyTypeDescription`body`arrayKeys represent the compiler name, values contain the method body for the given compiler`comment`stringThe method's comment`returnType`\*The return type, resource identifier or one of the following types:
**array**
**integer**An example:

```
body:
  php-core: return $this->rules;
comment: Get the rules for this model
returnType: array
```

\## Property configuration A property can be added to class resources, or subclasses thereof (models, controllers, etc.)

KeyTypeDescription`value`\*The value of the property`comment`stringThe property's commentAn example:

```
value:
  name: required
  email: required|email
comment: The rules for this model
```

\## Relation configuration A relation can be added to a model resource, or subclasses thereof

KeyTypeDescription`type`\*The type of the relation`other`stringThe other resourceAn example:

```
type: hasMany
other: Models.TrailCategory
```

\## Column configuration A column can be added to a model resource, or subclasses thereof

KeyTypeDescription`type`\*The type of the column`max`stringThe max size`nullable`booleanIndicates if the columns is nullableAn example:

```
type: string
max: 255
nullable: true
```

Generate from CLI
=================

[](#generate-from-cli)

The generator can take your input file and spit out JSON, or save the files to their calculated destinations. The input can even be a folder, if that's the case, Cody will use the top 2 folders as the package name, and all the folders below indicate the namespace. The files found in the deepest folders represent the resource name, and the contents of the file represent the resource configuration. An example of this setup can be found in `vendor/cody/example`

`./generator generate [--format="yml"] [--save] [--path="."] [--json] [--sync] [path]`

Arguments
---------

[](#arguments)

ArgumentDescriptionpathpath to file or directory containing config codeOptions
-------

[](#options)

OptionDescription--formatSpecify the input format (default: "yml")

Available options are:
**yml**
**json**
**stdin**--saveSave code code to path--pathSet the path for files (default: ".")--jsonReturn files as JSON--syncSync code with databaseGenerate from PHP
=================

[](#generate-from-php)

1. add this following line to the `require` section in your `composer.json`

`"layla/cody": "dev-master"`

2. run `composer update`
3. Register Cody's services by calling the following code

```
use Layla\Cody\CodyServiceProvider;
use Illuminate\Container\Container as Application;

$app = new Application;
$provider = new CodyServiceProvider($app);
$provider->register();
```

In case you already have a (compatible) container, you can pass that into the ServiceProvider.

4. Profit!

```
$input = array(
  'package' => 'Example.Package',
  'resources' => array(
    'Models.News' => array(
      'model' => array(
        'relations' => array(
          'categories' => array(
            'other' => 'Models.Category'
          )
        )
      ),
      'compilers' => array(
        'laravel-php'
      )
    )
  )
);

$files = $app->make('cody')->compileInput($input);

// Or, if you like your input to be parsed, specify the name of the parser as the second argument (gotta love YAML :)

$input = "
package: Example.Package
resources:
  Models.News:
    model:
      relations:
        categories:
          other: Models.Category
    compilers:
      laravel-php
";

$files = $app->make('cody')->compileInput($input, 'yml');

// Or json if you like

$input = '
{
  "package": "Example.Package",
  "resources": {
    Models."News": {
      "model": {
        "relations": {
          "categories": {
            "other": "Models.Category"
          }
        }
      }
      "compilers": [
        "laravel-php"
      ]
    }
  }
}';

$files = $app->make('cody')->compileInput($input, 'json');

foreach($files as $filename => $content)
{
  // save it, echo it, do whatever you want to do with it
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

3

Last Release

4412d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/beb3e5e89606ac13954df233e7b6465cf7eba8c01c9c1c64b30ac9fbc020e312?d=identicon)[Vespakoen](/maintainers/Vespakoen)

---

Top Contributors

[![vespakoen](https://avatars.githubusercontent.com/u/876117?v=4)](https://github.com/vespakoen "vespakoen (39 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/layla-cody/health.svg)

```
[![Health](https://phpackages.com/badges/layla-cody/health.svg)](https://phpackages.com/packages/layla-cody)
```

###  Alternatives

[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
