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 Slim Basics & Twig Templates Installing The Slim Framework

Qasim Hafeez
Qasim Hafeez
12,731 Points

How do I require version ~2.6?

I'm using composer on my mac, not workspaces. Everything has been working fine but I can't seem to specify the version the instructor says. This is how my terminal looks

Search for a package: slim

Found 15 packages matching slim

   [0] slim/slim
   [1] afief/slim
   [2] endel/slim
   [3] ivandokov/slim
   [4] akrabat/slim3-skeleton
   [5] slim/slim-skeleton
   [6] martynbiz/slim3-controller
   [7] rotexsoft/slim3-skeleton-mvc-tools
   [8] mrcoco/slim3-eloquent-skeleton
   [9] shameerc/slim3-aura-di
  [10] vhchung/slim3-skeleton-mvc
  [11] hossamyousef/slim3-minify
  [12] rotexsoft/slim3-skeleton-mvc-app
  [13] slim/views
  [14] l0gin/slim-3-poo-skeleton

Enter package # to add, or the complete package name if it is not listed: 0
Enter the version constraint to require (or leave blank to use the latest version): ~2.6
Search for a package: 

After I type in "~2.6", nothing happens. It just says "Search for a package:"

2 Answers

Mike Costa
PLUS
Mike Costa
Courses Plus Student 26,362 Points

One way to do it is you can add the version to your composer.json file. Something like:

  "require": {
         // ...... other packages
        "slim/slim": "~2.6"
}

Then save that file and run "composer update" in your terminal, and that will install the newly added package (and update existing ones).

Qasim Hafeez
Qasim Hafeez
12,731 Points

That's how I ended up doing it. In the video the instructor does it through the console so I was trying to do it that way. Thanks.

What's happening is composer is allowing you to search for additional packages. If you wanted to search for another package at that time you could do so at the

Search for a package:

prompt. Otherwise, if you're are done requiring packages for your project just leave it blank and press enter and composer will grab the packages you specified. In your case slim/slim with a specified version constraint of ~2.6.