Describe PHP dependencies and distinguish installation from updates.

Before starting: Basic PHP and a terminal.

Practice project: Extend the examples into a small Composer study demo. Explain the setup, one normal case and one failure or boundary case.

Start here: concepts and guided practice

  1. Composer: describe a PHP project

    composer.json describes project requirements. A PHP platform constraint is not a PHP download. Composer checks the active runtime against it.

    Composer installed alongside a compatible PHP CLI; work in a disposable project directory.

    {
      "name": "student/study-demo",
      "require": {"php": ">=8.2"}
    }
    Check the output
    This manifest declares PHP 8.2 or later as a runtime requirement.

    Explain why editing the constraint does not upgrade PHP.

  2. Composer: install versus update

    For an existing application with a lock file, install uses its recorded dependency versions. update resolves versions allowed by the manifest and changes the lock file. Review updates before sharing them.

    Composer installed alongside a compatible PHP CLI; work in a disposable project directory.

    composer install
    # Run intentionally when updating dependencies:
    composer update
    Check the output
    Installed packages and messages depend on the project; update can change composer.lock.

    Describe why teammates should share the application lock file.

Open the Composer learning path on DevStudyHub · Play coding games on this blog

logoblog

No comments:

Post a Comment

Please do not enter any spam link in the comment box.