Reading a composer.json

Exercise 1 of 4 in chapter 4 · 100 XP · 4 objectives checked by tests

Topics covered: Composercomposer.jsonJSONDependency

Odette's nephew, him again, explains that “nobody writes their autoloader by hand anymore.” Everyone uses Composer, the tool that manages PHP projects. Good news: the gazette already has a composer.json file. It has been sitting there since the very beginning, and nobody has ever opened it.

Your mission

  1. Open composer.json and find its sections: require (what the project needs to run), require-dev (what is only needed during development, like the tests) and config.
  2. Give the project a name: "name": "saint-glinglin/gazette".
  3. Add a description: "description": "The online newspaper of Saint-Glinglin".
  4. Leave the dependencies alone: PHPUnit, in require-dev, is what runs this exercise's tests.

Reminder

Composer reads composer.json to find out what a project needs, downloads these dependencies into vendor/, and writes down their exact versions in composer.lock. The file is written in JSON: keys and strings in double quotes, commas between entries, never after the last one.