2017 © Pedro Peláez
 

yii-extension yii-caviar

Next generation code generation for Yii.

image

crisu83/yii-caviar

Next generation code generation for Yii.

  • Wednesday, May 28, 2014
  • by crisu83
  • Repository
  • 3 Watchers
  • 10 Stars
  • 109 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 0 % Grown

The README.md

Caviar

Code generation with logic-less templates for Yii., (*1)

Caviar vs Gii

You might be wondering why you should use Caviar instead of Gii, so let us take a look at how they differ from each other., (*2)

The main disadvantage with Gii is that it is troublesome to write templates for it. Have you ever looked at one of its templates? If you have you know that they are quite hard to read. Compare the following template in Gii to the corresponding template in Caviar., (*3)

Caviar uses plain text (.txt files) templates, which are compiled into php files to apply separation of concerns. This means that all logic must be contained in the generator and that only strings can be passed to the template. Instead of doing logical operations within the template we do them in the generator when we create the data for the template. You can take a look at the model generator for an example on this., (*4)

Convinced? Follow the instructions below to install Caviar., (*5)

Installation

The preferred way to install this extension is through composer., (*6)

Either run, (*7)

php composer.phar require --prefer-dist crisu83/yii-caviar "*"

or add, (*8)

"crisu83/yii-caviar": "*"

to the require section of your composer.json file., (*9)

Usage

Add the a command to your console application configuration:, (*10)

return array(
  ...
  'commandMap' => array(
    'generate' => array(
      'class' => '\crisu83\yii_caviar\Command',
      'basePath' => '<path-to-project-root>',
    ),
    ...
  ),
);

When that is done you can use it to generate code:, (*11)

yiic generate generator [context:]subject [options]

Where generator is the name of the generator, context is the name of your application (e.g. app) and subject is a name for the item that will be generated., (*12)

You can view the command help by running the following command:, (*13)

yiic generate help

Or the help for a particular generator by appending -t (or --help) to your command:, (*14)

yiic generate component --help

Disable namespaces

Caviar uses namespaces by default, mainly because it has a proven to be a good practice in large scale applications, but it also allows you to easily disable namespaces for all generators., (*15)

Disabling namespaces for all generators can easily be done by adding the following to your configuration:, (*16)

'generate' => array(
  ...
  'defaultTemplate' => 'noNamespaces',
  'enableNamespaces' => false,
  'templates' => array(
    'noNamespaces' => '<path-to-caviar>/templates/no-namespaces',
  ),
)

Fancy UI

Caviar has a fancy UI, here are a few screenshots showing the UI., (*17)

  • https://www.dropbox.com/s/x29drr6ldkku7ft/Screenshot%202014-03-20%2017.32.20.png
  • https://www.dropbox.com/s/vrr0vj709xtxba4/Screenshot%202014-03-20%2017.36.31.png
  • https://www.dropbox.com/s/0mm2x6g1ad7d5fz/Screenshot%202014-03-20%2017.39.26.png

Generators

The following generators are already supported:, (*18)

  • component
  • config
  • controller
  • layout
  • model
  • view
  • webapp

The following generators are planned to be included in the first release:, (*19)

  • action
  • crud
  • widget

The Versions

28/05 2014

dev-develop

dev-develop

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

template command code scaffold yii generation

22/05 2014

dev-master

9999999-dev

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

template command code scaffold yii generation

22/05 2014

0.15.0

0.15.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

template command code scaffold yii generation

22/05 2014

dev-feature/providers

dev-feature/providers

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

template command code scaffold yii generation

13/05 2014

0.14.0

0.14.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

template command code scaffold yii generation

21/03 2014

0.12.0

0.12.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

20/03 2014

0.11.0

0.11.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

19/03 2014

0.10.0

0.10.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

19/03 2014

0.9.0

0.9.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

19/03 2014

0.8.0

0.8.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

18/03 2014

0.7.0

0.7.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

17/03 2014

0.6.0

0.6.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

17/03 2014

0.5.0

0.5.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

16/03 2014

0.4.0

0.4.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

15/03 2014

0.3.0

0.3.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

15/03 2014

0.2.0

0.2.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause

15/03 2014

0.1.0

0.1.0.0

Next generation code generation for Yii.

  Sources   Download

BSD-3-Clause