From aab50b0401df96abff44ccce59abee399cf86742 Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Sun, 11 Dec 2022 14:48:30 +0800 Subject: [PATCH] php refactored and new tools --- install/{composer-clean => composer} | 14 ++++++++- install/php | 27 ++++++++-------- install/php-psalm | 31 +++++++++++++++++++ install/php-spx | 46 ++++++++++++++++++++++++++++ install/php-tools-only | 41 ------------------------- install/phpcs | 32 +++++++++++++++++++ install/phpmd | 30 ++++++++++++++++++ install/phpstan | 30 ++++++++++++++++++ install/phpunit | 30 ++++++++++++++++++ packs/composer | 2 -- packs/flameshot | 6 ++-- packs/lamp | 7 +++-- packs/obs | 6 ++-- packs/omz | 7 +++-- packs/php-stack | 4 +++ packs/php-tools | 9 ++++++ packs/phptools | 2 -- 17 files changed, 258 insertions(+), 66 deletions(-) rename install/{composer-clean => composer} (83%) create mode 100755 install/php-psalm create mode 100755 install/php-spx delete mode 100755 install/php-tools-only create mode 100755 install/phpcs create mode 100755 install/phpmd create mode 100755 install/phpstan create mode 100755 install/phpunit delete mode 100644 packs/composer create mode 100644 packs/php-stack create mode 100644 packs/php-tools delete mode 100644 packs/phptools diff --git a/install/composer-clean b/install/composer similarity index 83% rename from install/composer-clean rename to install/composer index b034639..4fc8693 100755 --- a/install/composer-clean +++ b/install/composer @@ -39,4 +39,16 @@ fi php composer-setup.php --quiet cp $HOME/install/composer.phar $HOME/.local/bin/composer cd - >/dev/null -installed "composer" && composer --version + +COMPOSER_GLOBAL_HOME="$(composer config -g home)" +NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\"" +cat "${HOME}/.profile" | grep -qoh "$NEWPATH" || { + $NEWPATH + echo "$NEWPATH" >> "${HOME}/.profile" +} + +echo +echo "Finish!" +echo + +composer --version diff --git a/install/php b/install/php index 471b43a..d6701bd 100755 --- a/install/php +++ b/install/php @@ -11,24 +11,27 @@ echo sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php sudo apt install -y --autoremove \ php${PHPVER} \ + php${PHPVER}-apcu \ + php${PHPVER}-bcmath \ php${PHPVER}-cli \ php${PHPVER}-common \ - php${PHPVER}-xdebug \ - php${PHPVER}-dom \ php${PHPVER}-curl \ - php${PHPVER}-bcmath \ + # php${PHPVER}-dba \ + php${PHPVER}-dev \ + php${PHPVER}-dom \ php${PHPVER}-gd \ php${PHPVER}-intl \ + # php${PHPVER}-ldap \ php${PHPVER}-mbstring \ - # php${PHPVER}-mysql \ - # php${PHPVER}-opcache \ - # php${PHPVER}-pgsql \ + php${PHPVER}-mysql \ + php${PHPVER}-opcache \ + php${PHPVER}-pgsql \ php${PHPVER}-soap \ - # php${PHPVER}-xml \ - # php${PHPVER}-xmlrpc \ + php${PHPVER}-sqlite3 \ + php${PHPVER}-xdebug \ + php${PHPVER}-xml \ + php${PHPVER}-xmlrpc \ # php${PHPVER}-xsl \ - # php${PHPVER}-sqlite3 \ - # php${PHPVER}-zip \ - # php${PHPVER}-dba \ - # php${PHPVER}-ldap + php${PHPVER}-zip + php -v diff --git a/install/php-psalm b/install/php-psalm new file mode 100755 index 0000000..35b1300 --- /dev/null +++ b/install/php-psalm @@ -0,0 +1,31 @@ +#!/bin/bash +##makedesc: Install psalm + +echo +echo "===============================================" +echo "Installing psalm..." +echo "===============================================" +echo + +installed() { + command -v "$1" >/dev/null 2>&1 +} + +! installed 'php' && echo 'ERROR: You need php to be installed' && exit 1 +! installed "composer" && echo "ERROR: You need composer to be installed" && exit 2 + +COMPOSER_GLOBAL_HOME="$(composer config -g home)" +NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\"" +cat "${HOME}/.profile" | grep -qoh "$NEWPATH" || { + $NEWPATH + echo "$NEWPATH" >> "${HOME}/.profile" +} + +composer global require vimeo/psalm --dev + +echo +echo "Finish!" +echo + +phpcs --version # phpcbf --version +php-cs-fixer --version diff --git a/install/php-spx b/install/php-spx new file mode 100755 index 0000000..4e8351b --- /dev/null +++ b/install/php-spx @@ -0,0 +1,46 @@ +#!/bin/bash +##makedesc: Install php-spx + +echo +echo "===============================================" +echo "Installing php-spx..." +echo "===============================================" +echo + +installed() { + command -v "$1" >/dev/null 2>&1 +} + +! installed 'php' && echo 'ERROR: You need php to be installed' && exit 1 +! installed 'phpize' && echo 'ERROR: You need php-dev to be installed' && exit 2 +! installed 'make' && sudo apt install -y make +! installed 'wget' && sudo apt install -y wget + +[ -d "${HOME}/install/php-spx" ] || mkdir -p "${HOME}/install/php-spx" +wget https://github.com/NoiseByNorthwest/php-spx/archive/refs/heads/release/latest.zip -O /tmp/php-spx.zip \ + && unzip -oq /tmp/php-spx.zip -d "${HOME}/install/php-spx" \ + && rm /tmp/php-spx.zip \ + && cd "${HOME}/install/php-spx/php-spx-release-latest" \ + && phpize \ + && ./configure \ + && make \ + && sudo make install + +PHPVER=`php -r 'echo ($v=explode(".",PHP_VERSION))[0].".".$v[1];'` +cat << EOF | sudo tee -a "/etc/php/${PHPVER}/mods-available/spx.ini" +; https://github.com/NoiseByNorthwest/php-spx/tree/release/latest#configuration +; https://habr.com/ru/post/505192/ + +; extension=spx.so +; spx.data_dir = '/tmp/spx' +spx.http_enabled = 0 +spx.http_key = 'spx' +; spx.http_ip_whitelist = "127.0.0.1" + +EOF + +sudo ln -sf "/etc/php/${PHPVER}/mods-available/spx.ini" "/etc/php/${PHPVER}/cli/conf.d/99-spx.ini" + +echo +echo "Finish!" +echo diff --git a/install/php-tools-only b/install/php-tools-only deleted file mode 100755 index 9cf7bff..0000000 --- a/install/php-tools-only +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -##makedesc: Install phpunit + psalm + phpcs + php-cs-fixer - -echo -echo "===============================================" -echo "Installing phpunit + psalm + phpcs + php-cs-fixer..." -echo "===============================================" -echo - -installed() { - command -v "$1" >/dev/null 2>&1 -} - -! installed "php" && echo "ERROR: You need php to be installed" && exit 1 -! installed "composer" && echo "ERROR: You need composer to be installed" && exit 2 - -composer global require phpunit/phpunit --dev -composer global require phpmd/phpmd --dev -composer global require squizlabs/php_codesniffer --dev -composer global require friendsofphp/php-cs-fixer --dev -composer global require vimeo/psalm --dev -composer global require phpstan/phpstan --dev -# composer global require phpunit/dbunit -# composer global require phing/phing -# composer global require phpdocumentor/phpdocumentor -# composer global require sebastian/phpcpd -# composer global require phploc/phploc - -export PATH="$(composer config -g home)/vendor/bin:${PATH}" -echo 'export PATH="$(composer config -g home)/vendor/bin:${PATH}"' >> "${HOME}/.profile" - -phpunit --version -phpmd --version -phpcs --version # phpcbf --version -php-cs-fixer --version -psalm --version -phpstan --version - -echo -echo "Finish!" -echo diff --git a/install/phpcs b/install/phpcs new file mode 100755 index 0000000..d429411 --- /dev/null +++ b/install/phpcs @@ -0,0 +1,32 @@ +#!/bin/bash +##makedesc: Install phpcs + php-cs-fixer + +echo +echo "===============================================" +echo "Installing phpcs + php-cs-fixer..." +echo "===============================================" +echo + +installed() { + command -v "$1" >/dev/null 2>&1 +} + +! installed 'php' && echo 'ERROR: You need php to be installed' && exit 1 +! installed "composer" && echo "ERROR: You need composer to be installed" && exit 2 + +COMPOSER_GLOBAL_HOME="$(composer config -g home)" +NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\"" +cat "${HOME}/.profile" | grep -qoh "$NEWPATH" || { + $NEWPATH + echo "$NEWPATH" >> "${HOME}/.profile" +} + +composer global require squizlabs/php_codesniffer --dev +composer global require friendsofphp/php-cs-fixer --dev + +echo +echo "Finish!" +echo + +phpcs --version # phpcbf --version +php-cs-fixer --version diff --git a/install/phpmd b/install/phpmd new file mode 100755 index 0000000..c589ecb --- /dev/null +++ b/install/phpmd @@ -0,0 +1,30 @@ +#!/bin/bash +##makedesc: Install phpmd + +echo +echo "===============================================" +echo "Installing phpmd..." +echo "===============================================" +echo + +installed() { + command -v "$1" >/dev/null 2>&1 +} + +! installed 'php' && echo 'ERROR: You need php to be installed' && exit 1 +! installed "composer" && echo "ERROR: You need composer to be installed" && exit 2 + +COMPOSER_GLOBAL_HOME="$(composer config -g home)" +NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\"" +cat "${HOME}/.profile" | grep -qoh "$NEWPATH" || { + $NEWPATH + echo "$NEWPATH" >> "${HOME}/.profile" +} + +composer global require phpmd/phpmd --dev + +echo +echo "Finish!" +echo + +phpmd --version diff --git a/install/phpstan b/install/phpstan new file mode 100755 index 0000000..835a314 --- /dev/null +++ b/install/phpstan @@ -0,0 +1,30 @@ +#!/bin/bash +##makedesc: Install phpstan + +echo +echo "===============================================" +echo "Installing phpstan..." +echo "===============================================" +echo + +installed() { + command -v "$1" >/dev/null 2>&1 +} + +! installed 'php' && echo 'ERROR: You need php to be installed' && exit 1 +! installed "composer" && echo "ERROR: You need composer to be installed" && exit 2 + +COMPOSER_GLOBAL_HOME="$(composer config -g home)" +NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\"" +cat "${HOME}/.profile" | grep -qoh "$NEWPATH" || { + $NEWPATH + echo "$NEWPATH" >> "${HOME}/.profile" +} + +composer global require phpstan/phpstan --dev + +echo +echo "Finish!" +echo + +phpstan --version diff --git a/install/phpunit b/install/phpunit new file mode 100755 index 0000000..525c705 --- /dev/null +++ b/install/phpunit @@ -0,0 +1,30 @@ +#!/bin/bash +##makedesc: Install phpunit + +echo +echo "===============================================" +echo "Installing phpunit..." +echo "===============================================" +echo + +installed() { + command -v "$1" >/dev/null 2>&1 +} + +! installed 'php' && echo 'ERROR: You need php to be installed' && exit 1 +! installed "composer" && echo "ERROR: You need composer to be installed" && exit 2 + +COMPOSER_GLOBAL_HOME="$(composer config -g home)" +NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\"" +cat "${HOME}/.profile" | grep -qoh "$NEWPATH" || { + $NEWPATH + echo "$NEWPATH" >> "${HOME}/.profile" +} + +composer global require phpunit/phpunit --dev + +echo +echo "Finish!" +echo + +phpunit --version diff --git a/packs/composer b/packs/composer deleted file mode 100644 index c09e316..0000000 --- a/packs/composer +++ /dev/null @@ -1,2 +0,0 @@ -# [PACK] php + composer -composer: php composer-clean diff --git a/packs/flameshot b/packs/flameshot index d6416f3..9b11b26 100644 --- a/packs/flameshot +++ b/packs/flameshot @@ -1,2 +1,4 @@ -# [TODO] [PACK] qt5 + flameshot from source -flameshot: qt5 flameshot-build +# [TODO] [PACK] Install qt5 + flameshot from source +flameshot: + qt5 + flameshot-build diff --git a/packs/lamp b/packs/lamp index b2c385a..9d1b76d 100644 --- a/packs/lamp +++ b/packs/lamp @@ -1,2 +1,5 @@ -# [PACK] Apache + php + mariadb -lamp: apache php mariadb +# [PACK] Install apache + php + mariadb +lamp: + apache + php-stack + mariadb diff --git a/packs/obs b/packs/obs index 37bcfed..ec4208f 100644 --- a/packs/obs +++ b/packs/obs @@ -1,2 +1,4 @@ -# [PACK] OBS Studio + droidcam-obs -obs: obs-studio droidcam-obs +# [PACK] Install OBS Studio + droidcam-obs +obs: + obs-studio + droidcam-obs diff --git a/packs/omz b/packs/omz index 79e62c7..7bcbdab 100644 --- a/packs/omz +++ b/packs/omz @@ -1,4 +1,7 @@ -# [PACK] zsh + omz + powerline10k + MesloLGS font -omz: zsh omz-clean omz-fancy +# [PACK] Install zsh + omz + powerline10k + MesloLGS font +omz: + zsh + omz-clean + omz-fancy chsh -s /usr/bin/zsh @exec zsh diff --git a/packs/php-stack b/packs/php-stack new file mode 100644 index 0000000..7e4dfa2 --- /dev/null +++ b/packs/php-stack @@ -0,0 +1,4 @@ +# [PACK] Install full php stack with tooling +phptools: + php + php-tools diff --git a/packs/php-tools b/packs/php-tools new file mode 100644 index 0000000..16a46ce --- /dev/null +++ b/packs/php-tools @@ -0,0 +1,9 @@ +# [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, php-spx, phpmd) +php-stack: + composer + php-psalm + php-spx + phpcs + phpmd + phpstan + phpunit diff --git a/packs/phptools b/packs/phptools deleted file mode 100644 index 01cdfde..0000000 --- a/packs/phptools +++ /dev/null @@ -1,2 +0,0 @@ -# [PACK] php + composer + phpunit + psalm + phpcs + php-cs-fixer -phptools: php composer-clean php-tools-only