Pecl install spool installation error: fatal error: pcre2. h: No such file or directory Author: Chuwen Time: 2023-09-19 Classification: PHP , Other classifications comment Installation error log: ```log In file included from /home/linuxbrew/.linuxbrew/Cellar/ php@8.1 /8.1.23/include/php/ext/spl/spl_iterators.h:22, from /home/linuxbrew/.linuxbrew/Cellar/ php@8.1 /8.1.23/include/php/ext/spl/spl_array.h:22, from /tmp/pear/temp/swoole/ext-src/swoole_coroutine.cc:27: /home/linuxbrew/.linuxbrew/Cellar/ php@8.1 /8.1.23/include/php/ext/pcre/php_pcre.h:23:10: fatal error: pcre2.h: No such file or directory 23 | #include "pcre2.h" | ^~~~~~~~~ compilation terminated. make: *** [Makefile:233: ext-src/swoole_coroutine.lo] Error 1 ERROR: `make' failed ``` ##Error reason This error message indicates that the pcre2. h header file is missing in the compilation or construction process, so it cannot be found. Pcre2. h is the header file of PCRE2 (Perl Compatible Regular Expressions) library, which is usually used for regular expression operations. ##Solution **Installing the PCRE2 Library** On Ubuntu/Debian: ```shell sudo apt-get install libpcre2-dev ``` On CentOS/RHEL: ```shell sudo yum install pcre2-devel ``` On macOS, you can use Homebrew to install: ```shell brew install pcre2 ``` Finally, the solution is perfect. I normally install the 'swoole' extension here ``` Build process completed successfully Installing '/home/linuxbrew/.linuxbrew/Cellar/ php@8.1 /8.1.23/pecl/20210902/swoole.so' Installing '/home/linuxbrew/.linuxbrew/Cellar/ php@8.1 /8.1.23/include/php/ext/swoole/config.h' Installing '/home/linuxbrew/.linuxbrew/Cellar/ php@8.1 /8.1.23/include/php/ext/swoole/php_swoole.h' install ok: channel://pecl.php.net/swoole-5.0.3 Extension swoole enabled in php.ini ```
Read the. env environment variable file and use mysqldump to export the database Author: Chuwen Time: 2022-12-10 Classification: Other classifications comment ##Code If you do not have mysqldump, you can use this command to install<CentOS system only> ```shell yum install -y holland-mysqldump.noarch ``` --- ```shell #!/ bin/bsh function echo_error() { [ $# -ne 1 ] && return 0 echo -e "\033[31m $1 \033[0m" } function echo_danger() { [ $# -ne 1 ] && return 0 echo -e "\033[41;37m $1 \033[0m" } function echo_info() { [ $# -ne 1 ] && return 0 echo -e "\033[32m $1 \033[0m" } function echo_success() { [ $# -ne 1 ] && return 0 echo -e "\033[42;37m $1 \033[0m" } function echo_warning() { [ $# -ne 1 ] && return 0 echo -e "\033[33m $1 \033[0m" } function now_time() { echo $(date '+%Y-%m-%d %H:%M:%S') } if [ ! -f ".env" ]; then Echo_danger ". env does not exist, terminate execution" exit 127 fi #Import the. env file into environment variables (excluding comment lines) export $(cat .env | grep -v "^#") #Export the first 1000 pieces of data in each table function export_limit_1000() { mysqldump --column-statistics=0 \ --host="${DB_HOST}" \ --user="${DB_USERNAME}" --password="${DB_PASSWORD}" \ "${DB_DATABASE}" \ --where="true limit 1000" >mysqldump_"$(date '+%Y-%m-%d_%H:%M:%S')".sql } function export_sql() { Echo_info "[` now_time `]>>>Start exporting database" mysqldump --column-statistics=0 \ --host="${DB_HOST}" \ --user="${DB_USERNAME}" --password="${DB_PASSWORD}" \ "${DB_DATABASE}" \ >mysqldump_"$(date '+%Y-%m-%d_%H:%M:%S')".sql Echo_success "[` now_time `]<<Export database completed" } export_sql ``` ##Execution results ! []( https://cdn.nowtime.cc/2022/12/10/3529888146.png )
React converts svg to React component Author: Chuwen Time: 2022-02-07 Classification: Other classifications comment SVGR: https://react-svgr.com/docs/cli/ ##Conversion Convert the 'svg' file in the current path to 'tsx' and clearly use the hump naming method ```shell npx @svgr/cli --out-dir . -- ext tsx -- * ``` See the project documentation for more commands ##Using You can use it by importing directly
Determine which fields have been changed before/after saving the model Author: Chuwen Time: 2021-08-21 Classification: Other classifications comment ##Code example ```php $user = User::whereId(1); $user->email = 'i@nowtime.cc'; //Before submitting the update, obtain which fields have been modified $user->getDirty();// Return to ["email": "i @ nowtime. cc"] $user->save(); //After submitting the update, obtain which fields have been modified $user->getChanges();// Return to ["email": "i @ nowtime. cc"] ``` -'getDirty' called before updating -'getChanges' is called after updating
PHPStorm quick preview defined method/function code Author: Chuwen Time: 2021-06-11 Classification: Other classifications comment ###The shortcut key under mac is ` Alt+Space` ! []( https://cdn.nowtime.cc/2021/06/11/1836675584.png )