月度归档:2021年07月

Ubuntu下PHP 7和PHP 8多版本共存以及composer指定版本

修改更新源

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt upgrade

安装PHP7以及常用扩展

sudo apt install php7.4-common php7.4-cgi php7.4-gd php7.4-mysql php7.4-xml php7.4-cli php7.4-json php7.4-sqlite3 php7.4-xmlrpc php7.4-bcmath php7.4-enchant
php7.4-opcache php7.4-readline php7.4-xsl php7.4-bz2 php7.4-curl  php7.4-fpm php7.4-mbstring php7.4-pgsql php7.4-tidy php7.4-zip

安装PHP8以及常用扩展

sudo apt install php8.0-common php8.0-cgi php8.0-gd php8.0-mysql php8.0-xml php8.0-cli php8.0-sqlite3 php8.0-xmlrpc php8.0-bcmath php8.0-enchant php8.0-opcache php8.0-readline php8.0-xsl php8.0-bz2 php8.0-curl  php8.0-fpm php8.0-mbstring php8.0-pgsql php8.0-tidy php8.0-zip

composer安装以及使用

安装composer

php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

配置composer使用镜像

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

运行composer时指定PHP版本

php8.0 /usr/local/bin/composer
php7.4 /usr/local/bin/composer
alias composer7='php7.4 /usr/local/bin/composer'
alias composer8='php8.0 /usr/local/bin/composer'

使用symfony composer以及.php_version文件指定PHP版本

查看本地所有PHP版本

symfony local:php:list

显示结果

┌─────────┬────────────┬────────────┬─────────┬─────────┬─────────┬─────────┐
│ Version │ Directory  │  PHP CLI   │ PHP FPM │ PHP CGI │ Server  │ System? │
├─────────┼────────────┼────────────┼─────────┼─────────┼─────────┼─────────┤
│ 7.4.14  │ /usr/local │ bin/php    │         │         │ PHP CLI │ *       │
│ 7.4.16  │ /usr       │ bin/php7.4 │         │         │ PHP CLI │         │
└─────────┴────────────┴────────────┴─────────┴─────────┴─────────┴─────────┘

指定symfony composer使用PHP7

echo 7 > .php-version

指定symfony composer使用PHP8

echo 8 > .php-version

使用symfony composer安装或者更新包

symfony composer install

参考

Qt Windows CMakeLists.txt 注意事项

改为32位GUI启动

默认会出现命令行黑窗口,需要添加图形界面类型

if(WIN32)
    set(GUI_TYPE WIN32)
elseif(APPLE)
    set(GUI_TYPE MACOSX_BUNDLE)
endif()

add_executable(${CMAKE_PROJECT_NAME} ${GUI_TYPE} ${SRC} ${RES})

为QT应用添加管理员权限

set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\"")

解决复制dll错误问题

第一次复制成功后,注释以下代码

    foreach (QT_LIB ${REQUIRED_LIBS})
        add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                COMMAND ${CMAKE_COMMAND} -E copy
                "${QT_INSTALL_PATH}/bin/Qt${QT_VERSION}${QT_LIB}${DEBUG_SUFFIX}.dll"
                "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
    endforeach (QT_LIB)

设置CMAKE_PREFIX_PATH路径

set(CMAKE_PREFIX_PATH "D:\\Qt\\Qt5.12.9\\5.12.9\\msvc2017\\")