PHPackages                             crisu83/yii-caviar - 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. [Templating &amp; Views](/categories/templating)
4. /
5. crisu83/yii-caviar

ActiveYii-extension[Templating &amp; Views](/categories/templating)

crisu83/yii-caviar
==================

Next generation code generation for Yii.

0.15.0(11y ago)101242BSD-3-ClausePHPPHP &gt;=5.4.0

Since Mar 15Pushed 11y ago2 watchersCompare

[ Source](https://github.com/Crisu83/yii-caviar)[ Packagist](https://packagist.org/packages/crisu83/yii-caviar)[ RSS](/packages/crisu83-yii-caviar/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (17)Used By (2)

Caviar
======

[](#caviar)

Code generation with logic-less templates for Yii.

Caviar vs Gii
-------------

[](#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.

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](https://github.com/yiisoft/yii/blob/master/framework/gii/generators/model/templates/default/model.php) to the corresponding [template in Caviar](https://github.com/Crisu83/yii-caviar/blob/master/templates/default/model/model.txt).

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](https://github.com/Crisu83/yii-caviar/blob/master/generators/ModelGenerator.php) on this.

Convinced? Follow the instructions below to install Caviar.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

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

or add

```
"crisu83/yii-caviar": "*"
```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Add the a command to your console application configuration:

```
return array(
  ...
  'commandMap' => array(
    'generate' => array(
      'class' => '\crisu83\yii_caviar\Command',
      'basePath' => '',
    ),
    ...
  ),
);
```

When that is done you can use it to generate code:

```
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.

You can view the command help by running the following command:

```
yiic generate help
```

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

```
yiic generate component --help
```

Disable namespaces
------------------

[](#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.

Disabling namespaces for all generators can easily be done by adding the following to your configuration:

```
'generate' => array(
  ...
  'defaultTemplate' => 'noNamespaces',
  'enableNamespaces' => false,
  'templates' => array(
    'noNamespaces' => '/templates/no-namespaces',
  ),
)
```

Fancy UI
--------

[](#fancy-ui)

Caviar has a fancy UI, here are a few screenshots showing the UI.

-
-
-

Generators
----------

[](#generators)

The following generators are already supported:

- component
- config
- controller
- layout
- model
- view
- webapp

The following generators are planned to be included in the first release:

- action
- crud
- widget

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

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 ~5 days

Recently: every ~15 days

Total

14

Last Release

4374d ago

### Community

Maintainers

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

---

Top Contributors

[![cniska](https://avatars.githubusercontent.com/u/1044868?v=4)](https://github.com/cniska "cniska (48 commits)")

---

Tags

codescaffoldtemplatecommandyiigeneration

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/crisu83-yii-caviar/health.svg)

```
[![Health](https://phpackages.com/badges/crisu83-yii-caviar/health.svg)](https://phpackages.com/packages/crisu83-yii-caviar)
```

###  Alternatives

[phpoffice/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

7.5k34.7M186](/packages/phpoffice-phpword)[rize/uri-template

PHP URI Template (RFC 6570) supports both expansion &amp; extraction

420137.3M46](/packages/rize-uri-template)

PHPackages © 2026

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