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 trialGleb Sklyr
17,492 PointsSLIM FRAMEWORK
Hello everyone!
I have some questions about the Slim Framework! Would anyone be willing to help a little?
Okay!
First one:
<?php
$app->get('/product101', function() use($app){
$app->render('product101.twig');
})->name('product101');
?>
In the above, can I make the "101" part variable? and if I do, how do I access and change it?
2: Also, I'm using twig. I am trying to include an array and a few functions from a separate twig file but it says that and include can't have a body... any ides?
3: For posting from a form I use:
<?php
$name = $app->request->post('user_name');
?>
How do you post an image into a variable? or in general, how to receive an image from a form? I would probably need both html and slim sides explained.
I am really new to this, will appreciate the help! Also I would read good resources if you refer me please!
Thanks!
miikis
44,957 PointsHey Gleb,
I'm not too familiar with the Slim Framework, so I can't really help you there man. I did, however, edit your post so that you can take advantage of the syntax highlighting... so you can attract better answers.
Gleb Sklyr
17,492 PointsThanks! It seems quite difficult to find help for SLIM and twig
2 Answers
Ted Sumner
Courses Plus Student 17,967 PointsI suggest you take this course. It is based on Slim 2 and 3 will be released soon. I understand that the changes are going to be significant enough to make some of this course outdated, though.
Ted Sumner
Courses Plus Student 17,967 PointsQuestions 1 and 2 are addressed in the course. The course will give you a background that will allow you to understand and apply to other code as well.
With respect to the third questions, I am not 100% sure this is correct, but I think you have a user upload the picture using a different method. Storage of pictures in a database is typically really only storing a path to the picture that is stored in another folder. I am not aware of any courses here that teach how to do that. It is something that I want to figure out for a project of mine once I get other tasks done.
rhysadams
4,847 Pointsrhysadams
4,847 PointsHey Gleb, shoot! What's up?