-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
/vendor/ | ||
.* | ||
vendor/ | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# Laravel 4 specific | ||
bootstrap/compiled.php | ||
app/storage/ | ||
|
||
# Laravel 5 & Lumen specific | ||
public/storage | ||
public/hot | ||
|
||
# Laravel 5 & Lumen specific with changed public path | ||
public_html/storage | ||
public_html/hot | ||
|
||
storage/*.key | ||
.env | ||
Homestead.yaml | ||
Homestead.json | ||
/.vagrant | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
# php-extensions-toggle | ||
# PHP Extension Toggle | ||
Toggle php extensions from command line | ||
|
||
## How it works? | ||
- Search for all .ini files in php directory | ||
- Find line where specified extension loaded | ||
- Add or remove `;` at the beginning of the line | ||
- Try restart `fpm`, `apache` and `brew php` | ||
|
||
## Requirements | ||
- Linux or MacOs | ||
- Brew to restart php on mac os | ||
- `service` command to restart php-fpm or apache on linux | ||
|
||
## Install | ||
1. ```composer global require xtrime-ru/php-extensions-toggle``` | ||
|
||
## Usage | ||
``` | ||
php-extensions xdebug on | ||
php-extensions xdebug off | ||
php-extensions apcu on | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "xtrime-ru/php-extensions-toggle", | ||
"description": "Toggle php extensions from cli", | ||
"type": "project", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Alexander Pankratov", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"scripts": { | ||
"post-autoload-dump": [ | ||
"cp php-extension.sh /usr/local/bin/php-extension" | ||
], | ||
"post-package-uninstall": [ | ||
"rm /usr/local/bin/php-extension" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
EXTENSION="$1" | ||
[ "$2" == 'on' ] || [ "$2" == '1' ] || [ "$2" == 'enable' ] && ENABLE=true || ENABLE=false | ||
INI_DIR=$(php --ini | grep 'Configuration File (php.ini) Path:' | sed -E "s/.*: //") | ||
|
||
if [ "$EXTENSION" == '' ]; then | ||
echo 'Error: no extension provided' | ||
exit 1; | ||
fi | ||
|
||
#toogle extension line in .ini file: | ||
find "$INI_DIR" -type f -name "*.ini" | while read -r FILE; do | ||
if [ "$ENABLE" == true ]; then | ||
sed -i '' -E "s/^;((zend_extension|extension).+$EXTENSION\.so)$/\1/g" "$FILE" | ||
else | ||
sed -i '' -E "s/^((zend_extension|extension).+$EXTENSION\.so)$/;\1/g" "$FILE" | ||
fi | ||
done | ||
|
||
#restart fpm | ||
echo 'Restart fpm ...' | ||
PHP_VERSION=$(php -v | grep '^PHP ' | sed -E "s/^PHP ([0-9]\.[0-9]).*$/\1/") | ||
service php"$PHP_VERSION"-fpm restart 2> /dev/null | ||
service php-fpm restart 2> /dev/null | ||
|
||
#restart apache | ||
echo 'Restart apache ...' | ||
service apache2 restart 2> /dev/null | ||
|
||
#restart on MAC | ||
echo 'Restart brew php ...' | ||
brew services restart php@"$PHP_VERSION" 2> /dev/null | ||
|