1

When I've tried to link anchor like this:

<a href="{{ urlFor('posts.show', {'postId': post.id}) }}">{{ post.title }}</a>

I had a fatal error:

Class 'Twig_SimpleFunction' not found

1

But everything works perfect when I remove this link in the anchor. What could be the problem?

Vadym
  • 548
  • 2
  • 8
  • 21

2 Answers2

4

The "Twig_SimpleFunction" was introduced in the version between >1.11 and <=1.15, not in 1.x (as mentioned in the documentation). That's a wrong information from the documentation.

Please try to install the version 1.15 for example.

This issue was already reported here.

Community
  • 1
  • 1
zilongqiu
  • 846
  • 5
  • 12
  • can I somehow replace this part of code in anchor with new version of this feature? – Vadym Jul 14 '15 at 00:34
  • I don't understand what you mean by "replace this part of code in anchor with new version of this feature". Can you give me an example ? please – zilongqiu Jul 14 '15 at 00:44
0

Beware that urlFor() function is not defined by Twig. This means that your own project must define this function as a Twig extension before using it in a template.

If you are suing Symfony, the simplest solution is to change the custom urlFor() function by the built-in url() function:

<a href="{{ url('posts.show', {'postId': post.id}) }}">{{ post.title }}</a>
Javier Eguiluz
  • 3,987
  • 2
  • 23
  • 44