Download the PHP package layla/cody without Composer
On this page you can find all versions of the php package layla/cody. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package 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 for the generator is as following (example is given in yaml, other formats are supported too)
The root
The root of the input contains the package name the resources that exist within in the package.
Property | Description |
---|---|
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 that are present in the package |
Resources
The resources are defined with the names as the key, and the configurations as the value
Property | Description |
---|---|
name | The name property indicates the name as the key, and the resource configuration as value |
An example:
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:
Key | Type | Description |
---|---|---|
compilers |
array | Indicates what compilers should be used to compile the resource, available options are: php-core php-laravel js-core js-ember |
class |
class configuration | Indicates the resource is of type Class, value of this key is the configuration for the class |
model |
model configuration | Indicates the resource is of type Model, value of this key is the configuration for the model |
controller |
controller configuration | Indicates the resource is of type Controller, value of this key is the configuration for the controller |
The compiler expects the resource to ONLY contain the compilers
property and on of the available types.
An example:
Class configuration
The class configuration holds all the information we need to build a class. The available options are
Key | Type | Description |
---|---|---|
base |
string | Indicates the base class of this class |
properties |
property configuration | Keys represent the name of the property, values contain the property configuration |
methods |
method configuration | Keys represent the method name, values contain the method 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.
Key | Type | Description |
---|---|---|
base |
string | Indicates the base class of this class |
properties |
property configuration | Indicates the properties that should be present on the class |
methods |
method configuration | Indicates the methods that should be present on the class |
relations |
relation configuration | Indicates the relations that should be present on the model |
columns |
column configuration | Indicates the columns that should be present on the model |
Method configuration
A method can be added to class resources, or subclasses thereof (models, controllers, etc.)
Key | Type | Description |
---|---|---|
body |
array | Keys represent the compiler name, values contain the method body for the given compiler |
comment |
string | The method's comment |
returnType |
* | The return type, resource identifier or one of the following types: array integer |
An example:
Property configuration
A property can be added to class resources, or subclasses thereof (models, controllers, etc.)
Key | Type | Description |
---|---|---|
value |
* | The value of the property |
comment |
string | The property's comment |
An example:
Relation configuration
A relation can be added to a model resource, or subclasses thereof
Key | Type | Description |
---|---|---|
type |
* | The type of the relation |
other |
string | The other resource |
An example:
Column configuration
A column can be added to a model resource, or subclasses thereof
Key | Type | Description |
---|---|---|
type |
* | The type of the column |
max |
string | The max size |
nullable |
boolean | Indicates if the columns is nullable |
An example:
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
Argument | Description |
---|---|
path | path to file or directory containing config code |
Options
Option | Description |
---|---|
--format | Specify the input format (default: "yml") Available options are: yml json stdin |
--save | Save code code to path |
--path | Set the path for files (default: ".") |
--json | Return files as JSON |
--sync | Sync code with database |
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
In case you already have a (compatible) container, you can pass that into the ServiceProvider.
4) Profit!
All versions of cody with dependencies
illuminate/console Version ~4.2
illuminate/container Version ~4.2
illuminate/support Version ~4.2
illuminate/view Version ~4.2
illuminate/events Version ~4.2
sami/sami Version dev-master
jms/php-manipulator Version dev-master
nikic/php-parser Version 0.9.*