3
3
hashidsBundle
4
4
=============
5
5
6
- ##This is a bundle to use http://www.hashids.org/ as a service
6
+ ## This is a bundle to use http://www.hashids.org/ as a service
7
7
8
8
## Installation
9
9
10
-
11
10
#### Symfony 2.1.x <= 2.4.x: Composer
12
11
13
12
[ Composer] ( http://packagist.org/about-composer ) is a project dependency manager for PHP. You have to list
14
13
your dependencies in a ` composer.json ` file:
15
14
16
- ``` json
15
+ ``` json
17
16
{
18
17
"require" : {
19
18
"cayetanosoriano/hashids-bundle" : " dev-master"
@@ -22,7 +21,7 @@ your dependencies in a `composer.json` file:
22
21
```
23
22
To actually install in your project, download the composer binary and run it:
24
23
25
- ``` bash
24
+ ``` bash
26
25
wget http://getcomposer.org/composer.phar
27
26
# or
28
27
curl -O http://getcomposer.org/composer.phar
@@ -34,7 +33,7 @@ php composer.phar install
34
33
35
34
Finally, enable the bundle in the kernel:
36
35
37
- ``` php
36
+ ``` php
38
37
<?php
39
38
// app/AppKernel.php
40
39
@@ -49,16 +48,17 @@ public function registerBundles()
49
48
```
50
49
51
50
## Configuration
52
- ###Add the following to your config.yml
53
- ```
51
+
52
+ ### Add the following to your config.yml
53
+ ``` yaml
54
54
cayetanosoriano_hashids :
55
55
salt : " randomsalt" # optional
56
56
min_hash_length : 10 # optional
57
57
alphabet : " abcd..." # optional
58
58
` ` `
59
59
60
60
### Then use the service
61
- ```
61
+ ` ` ` php
62
62
$kcy = $this->get('hashids');
63
63
```
64
64
@@ -112,6 +112,24 @@ public function viewAction(User $user)
112
112
` ` `
113
113
114
114
# ## license
115
+ =======
116
+ # ## Twig extension
117
+
118
+ # ### Declare the service to your services.yml
119
+ ` ` ` yaml
120
+ twig.hashids_extension:
121
+ class: cayetanosoriano\H ashidsBundle\T wig\H ashidsExtension
122
+ arguments: ["@hashids"]
123
+ public: false
124
+ tags: [{ name: twig.extension }]
125
+ ` ` `
126
+
127
+ # ### Use the extension in your Twig templates
128
+ ` ` ` twig
129
+ <a href="{{ path('user_profile', {'hashid': user.id|hashid_encode}) }}">View Profile</a>
130
+ ` ` `
131
+
132
+ # ## License
115
133
```
116
134
Copyright (c) 2015 neoshadybeat[ at] gmail.com
117
135
0 commit comments