Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Composer can use a different PHP version #5

@svandragt

Description

@svandragt

Despite which php && php --version matching the desired version, composer commands can still not use the requested PHP version.

This makes it difficult to install a correct set of packages, if the packages are unique to the version of PHP in use.

Because of this, I'm not currently using php-activate myself, and changed my ~/.direnvrc to this:

# Usage: use php <version>
#
# Loads the specified php version into the environent
#
use_php() {
  if [[ "$OSTYPE" == "linux-gnu"* ]]; then
    php --version | grep -q "PHP $1" || (sudo update-alternatives --set php /usr/bin/php$1)
elif [[ "$OSTYPE" == "darwin"* ]]; then
    php --version | grep -q "PHP $1" || (brew unlink php@$1 &&  brew link php@$1 --force --overwrite)
else
    echo 'not implemented'
fi

  layout php
}

# Usage: use composer <version>
#
# Loads the specified composer version into the environent
#
use_composer() {
  composer --version | grep -q "version $1" || composer self-update --$1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions