PHPackages                             sarah-systems/ci4twig - 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. sarah-systems/ci4twig

ActiveLibrary[Templating &amp; Views](/categories/templating)

sarah-systems/ci4twig
=====================

CodeIgniter4 Twig Integration

0.1.2(6y ago)045MITPHPPHP &gt;=7.2

Since May 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/kohenji01/CI4Twig)[ Packagist](https://packagist.org/packages/sarah-systems/ci4twig)[ RSS](/packages/sarah-systems-ci4twig/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

CI4Twig
=======

[](#ci4twig)

CodeIgniter4用のTwig組み込みです。

Install
=======

[](#install)

Composerで導入可能です。CI4やTwigも予めComposerでインストールしておいてください。

```
$ composer require sarah-systems/ci4twig
```

Usage
=====

[](#usage)

デフォルトでは、Twig関連のパスは自体は次のような設定で動作するようになっています。

種類パステンプレートapp/Viewsキャッシュwritable/twig/cache`writable`が正しく書き込み可能な場合、下の3つのディレクトリは自動的に生成されます。 もしエラーが起きた場合は、これらのディレクトリを作って適切なパーミッションを与えることで動作します。

もしこのパスを変更したい場合は`.env`ファイルに次のパラメータをセットすることで、任意のパスに変更可能です。

```
CI4Twig.TemplateDir = /path/to/TemplateDir
CI4Twig.CacheDir = /path/to/CacheDir
```

これ以外にも`.env`では、TwigのDebugフラグのOn/Offとデフォルトの拡張子を設定できます。

```
CI4Twig.Debug = 1 または 0
CI4Twig.DefaultTemplateExtension = .html.twig
```

デフォルトの拡張子を設定すると、view()関数で

### view()

[](#view)

CI4のview関数をTwig用にCI4Twigというnamespaceで定義しています。

利用する際は`app`ディレクトリ直下の`Common.php`に次を追記してください。

```
require_once ROOTPATH . "vendor/sarah-systems/ci4twig/src/Common.php";
```

使用法はCI4のview関数と同じですが、関数の利用時には名前空間を指定するか、事前にエイリアスを張ってください。

```
\CI4Twig\view('template.html.twig');
```

または

```
use function CI4Twig\view as view;
view('template.html.twig');
```

拡張子`.html.twig`（`CI4Twig.DefaultTemplateExtension`で設定されたものです。無指定の場合は`.html.twig`）は省略可能です。

```
\CI4Twig\view('template');
```

view関数の第2パラメータはTwig変数`$CI`にアサインされます。

```
$data = [ 'apple' , 'banana' , 'lemon' ];
\CI4Twig\view('template',$data);
```

Twigのtemplate上では

```
{{ CI.0 }} ← appleが表示されます。
```

第3引数の$optionsは無視されます。

### Service

[](#service)

CI4のServiceが利用可能です。

```
use CI4Twig\Config\Services;

$time = date('Y-m-d H:i:s');
$twig = Services::twig();
$twig->Environment->addGlobal('time',$time);
$twig->Environment->display('template.html.twig');
```

License
=======

[](#license)

The source code is licensed MIT. The website content is licensed CC BY 4.0,see LICENSE.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Total

3

Last Release

2229d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8407272?v=4)[Shoji Ogura](/maintainers/kohenji01)[@kohenji01](https://github.com/kohenji01)

---

Top Contributors

[![kohenji01](https://avatars.githubusercontent.com/u/8407272?v=4)](https://github.com/kohenji01 "kohenji01 (7 commits)")

### Embed Badge

![Health badge](/badges/sarah-systems-ci4twig/health.svg)

```
[![Health](https://phpackages.com/badges/sarah-systems-ci4twig/health.svg)](https://phpackages.com/packages/sarah-systems-ci4twig)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[abydahana/aksara

Aksara is a CodeIgniter based CRUD Toolkit you can use to build complex applications become shorter, secure and more reliable just in a few lines of code. Serving both CMS or Framework, produce both HEADLESS (RESTful API) or TRADITIONAL (Browser Based), just by writing single controller. Yet it's reusable, scalable and ready to use!

1111.2k](/packages/abydahana-aksara)

PHPackages © 2026

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