# Twig Tema Kullanımı

> Kaynak: https://www.tasarimrehberi.net/twig-tema-kullanimi/
> Yazar: Nurettin Sezer
> Yayın: 2016-12-21 · Güncelleme: 2016-12-21

Öncelikle kullanabilmeniz için bilgisayarınızda comproser kurulu olması gerekiyor.

 

sonrasında işlem yapacagınız klasörün içine girererek

 

```
composer require "twig/twig:~1.0"
```

 

*:~1.0 bu kısmı silerseniz en son versiyonu kurabilirsiniz.

 

yazmanız yeterlidir. Artık kurulumu tamamlandı.

 

Basit olarak denemek isterseniz

 

```

&lt;?php
require_once 'vendor/autoload.php';

$loader = new Twig_Loader_Array(array(
'index' =&gt; 'Hello {{ name }}!',
));
$twig = new Twig_Environment($loader);

echo $twig-&gt;render('index', array('name' =&gt; 'Fabien'));
?&gt;
```

 

symfony gibi framework lerde hazır gelmektedir.

 

Bu yüzden extra olarak kurmanıza gerek yoktur. Bu yazıyı bilgi amaçlı sizlere ilettik. Sitesinden gerekli ayarları bakabilirsiniz.

 

Eskiden smarty kullanırdı şimdi symfony de cogu geliştirici twig kullandığı için popüler oldu.

 

Aşağıdaki kod sayesinde başka bir sayfayı yükleme yapabiliyoruz.

 

```

{% extends "layout.html.twig" %}[code]

Her sayfada kullanacaklarımızı extends ile yüklüyebiliyoruz.

ifdöngüsü kullanımı

<pre class="">[code]
{% if makalaler %}
{% endif %}

Blok kullanımı
{% block content %} içerikler burada { % endblock %}
Twig Tema Motorunun ideler için eklentileri var. Aşagıdakler gibi.
```

- *Textmate* via the [Twig bundle](https://github.com/Anomareh/PHP-Twig.tmbundle)
- *Vim* via the [Jinja syntax plugin](http://jinja.pocoo.org/docs/integration/#vim) or the [vim-twig plugin](https://github.com/evidens/vim-twig)
- *Netbeans* via the [Twig syntax plugin](http://plugins.netbeans.org/plugin/37069/php-twig) (until 7.1, native as of 7.2)
- *PhpStorm* (native as of 2.1)
- *Eclipse* via the [Twig plugin](https://github.com/pulse00/Twig-Eclipse-Plugin)
- *Sublime Text* via the [Twig bundle](https://github.com/Anomareh/PHP-Twig.tmbundle)
- *GtkSourceView* via the [Twig language definition](https://github.com/gabrielcorpse/gedit-twig-template-language) (used by gedit and other projects)
- *Coda* and *SubEthaEdit* via the [Twig syntax mode](https://github.com/bobthecow/Twig-HTML.mode)
- *Coda 2* via the [other Twig syntax mode](https://github.com/muxx/Twig-HTML.mode)
- *Komodo* and *Komodo Edit* via the Twig highlight/syntax check mode
- *Notepad++* via the [Notepad++ Twig Highlighter](https://github.com/Banane9/notepadplusplus-twig)
- *Emacs* via [web-mode.el](http://web-mode.org/)
- *Atom* via the [PHP-twig for atom](https://github.com/reesef/php-twig)
- *Visual Studio Code* via the [Twig pack](https://marketplace.visualstudio.com/items?itemName=bajdzis.vscode-twig-pack)
