PHP code example of layla / cody

1. Go to this page and download the library: Download layla/cody library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

layla / cody example snippets


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

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

$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
}
yaml
body:
  php-core: return $this->rules;
comment: Get the rules for this model
returnType: array