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

Commit bc7a9ef

Browse files
committed
BREAKING: updated usage to accommodate direnv
1 parent 0ac2244 commit bc7a9ef

File tree

3 files changed

+18
-51
lines changed

3 files changed

+18
-51
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ $ curl -# -L https://github.com/svandragt/php-activate/tarball/main | tar -xz --
2121

2222
## Setup
2323

24-
Add the following line to your shell rc script:
24+
Add the following line to your shell rc script (replace 8.2 with your default php version):
2525

2626
```
27-
# Fish
28-
source $HOME/opt/php-activate/php-activate.fish
29-
# Bash or ZSH:
30-
source $HOME/opt/php-activate/php-activate.sh
27+
source $HOME/opt/php-activate/php-activate.sh 8.2
3128
```
3229

3330

@@ -50,13 +47,13 @@ Zend Engine v4.1.15, Copyright (c) Zend Technologies
5047

5148
# Activate existing version
5249
$ php-activate 8.2
53-
Activated: /usr/bin/php8.2
50+
Activated /usr/bin/php8.2
5451
PHP 8.2.2 (cli) (built: Feb 7 2023 11:28:53) (NTS)
5552
...
5653

5754
# Deactivate (or use a different shell)
5855
$ php-activate
59-
Deactivated: /usr/bin/php8.2
56+
Deactivated /usr/bin/php8.2
6057
PHP 8.1.15 (cli) (built: Feb 7 2023 11:31:36) (NTS)
6158
...
6259
```
@@ -73,8 +70,7 @@ Add the following to `~/.direnvrc`:
7370
# Loads the specified php version into the environent
7471
#
7572
use_php() {
76-
source $HOME/opt/php-activate/php-activate.sh
77-
php-activate $1
73+
source $HOME/opt/php-activate/php-activate.sh $1
7874
layout php
7975
}
8076
```

php-activate.fish

Lines changed: 0 additions & 27 deletions
This file was deleted.

php-activate.sh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@ function php-activate {
77
if echo $VERSIONS | grep -q "$1"
88
then
99
export PHP_PICKED=$(echo "$VERSIONS" | sort | grep "$1" | head -n 1)
10-
function php {
11-
$PHP_PICKED $@
12-
}
13-
echo "Activated: $PHP_PICKED"
14-
php --version | grep built
15-
hash -r
10+
echo "Activated $PHP_PICKED"
1611
else
1712
echo "Error: No matching PHP version found. Use one of the following:"
1813
echo "$VERSIONS"
14+
return
1915
fi
20-
return
21-
fi
22-
23-
if ! [ -z $PHP_PICKED ]
24-
then
25-
echo "Deactivated: $PHP_PICKED"
26-
unset PHP_PICKED
27-
unset -f php
28-
php --version | grep built
16+
else
17+
echo "Deactivated $PHP_PICKED"
18+
unset -f php
2919
hash -r
3020
return
3121
fi
22+
function php {
23+
$PHP_PICKED $@
24+
}
25+
export -f php
26+
php --version | grep built
27+
hash -r
3228
}
29+
30+
php-activate $1

0 commit comments

Comments
 (0)