PHPackages                             scylabs/hook-bundle - 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. scylabs/hook-bundle

ActiveSymfony-bundle

scylabs/hook-bundle
===================

Templates and fonctionnal Hooks for symfony

1.0.6(5y ago)73.7k—0%MITPHPPHP ^7.2.5

Since Feb 18Pushed 5y ago2 watchersCompare

[ Source](https://github.com/ScyLabs/HookBundle)[ Packagist](https://packagist.org/packages/scylabs/hook-bundle)[ RSS](/packages/scylabs-hook-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (9)Used By (0)

ScyLabs Hook
============

[](#scylabs-hook)

Dynamic templating hook system for symfony.

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

[](#installation)

To install this package, use [composer](https://getcomposer.org/) .

```
composer require scylabs/hook-bundle
```

Usage
-----

[](#usage)

The operation is very simple. First, you need to create entry points in your template, then connect PHP classes to these entry points.
I will explain in detail.

### Create an entry point to connect hooks in twig

[](#create-an-entry-point-to-connect-hooks-in-twig)

Okay , for the rest of the tutorial, we will say that the "entry point" is a door.
You can use the TwigExtension provided in this package.
The extension function has two parameters.

```
public function showHook(string $template,string $hookName)
```

The first parameter is the target template NameSpace. Ex : layout.html.twig
The second parameter is the hook name and it is used to connect PHP classes in this door.

You can send \_self in first parameter. \_self is the current template NameSpace
It is important to add "raw" filter to interprete Hook's html.

```
{{ showHook(_self,'my_custom_hook')) | raw }}
```

### You don't use twig ?

[](#you-dont-use-twig-)

If you don't use twig , you can tell directly HooksFounder Service.
It works exactly like the extension, except that it directly returns an array of instantiated Hooks objects instead of hooks contents.

### Connect Hooks to an entry point (door).

[](#connect-hooks-to-an--entry-point-door)

You can create an infinity of doors and an infinity of hooks to connect this doors.
To connect a hook to one door , you need to create a PHP class that extends AbstractHook class
I'ts the minimal code to connect a hook to a door. PS : You can connect one hook to many doors.

```
