Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Building Websites with PHP Contact Form & Sending Email Named Routes

Mostafa Akram
PLUS
Mostafa Akram
Courses Plus Student 9,541 Points

neither urlFor() nor siteUrl() is working

i have tried urlFor('name') and siteUrl('/contact') and baseUrl() and i always get Twig_Error_Syntax Message Unknown function -one of them-

although i have installed "slim/slim": "^2.6", "twig/twig": "^1.23", "slim/views": "^0.1.3"

3 Answers

Dale Severude
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 Points

Hi Mostafa,

If these commands are not available, check to make sure this line of code is available in your index.php file. This is the line that loads them into your view.

$view->parserExtensions = array(
    new \Slim\Views\TwigExtension(),
);
Devin Gray
Devin Gray
39,261 Points

I just posted a solution in another thread for slim v3 if you still need help on this. You can look at the link here and try and look for a solution using the path_for() method.

http://www.slimframework.com/docs/features/templates.html

Thanks, Dale! I had misspelled this:

 $view->parserExtensions = array(
    new \Slim\Views\TwigExtension(),
);  

and got an error. re-checking that piece of code fixed it.