php refactored and new tools

This commit is contained in:
Anthony Axenov 2022-12-11 14:48:30 +08:00
parent 28692bfcf5
commit aab50b0401
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC
17 changed files with 258 additions and 66 deletions

View File

@ -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

View File

@ -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

31
install/php-psalm Executable file
View File

@ -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

46
install/php-spx Executable file
View File

@ -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

View File

@ -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

32
install/phpcs Executable file
View File

@ -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

30
install/phpmd Executable file
View File

@ -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

30
install/phpstan Executable file
View File

@ -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

30
install/phpunit Executable file
View File

@ -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

View File

@ -1,2 +0,0 @@
# [PACK] php + composer
composer: php composer-clean

View File

@ -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

View File

@ -1,2 +1,5 @@
# [PACK] Apache + php + mariadb
lamp: apache php mariadb
# [PACK] Install apache + php + mariadb
lamp:
apache
php-stack
mariadb

View File

@ -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

View File

@ -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

4
packs/php-stack Normal file
View File

@ -0,0 +1,4 @@
# [PACK] Install full php stack with tooling
phptools:
php
php-tools

9
packs/php-tools Normal file
View File

@ -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

View File

@ -1,2 +0,0 @@
# [PACK] php + composer + phpunit + psalm + phpcs + php-cs-fixer
phptools: php composer-clean php-tools-only