最近安装phalcon扩展遇到一点坑,这里回顾记录下,避免再次踩坑。
如果使用引擎搜索phalcon关键字最初的几条搜索结果,点击进去使用的均不是官方的phalcon扩展。
这里不用非官方的phalcon库(以后安装别的什么软件最好都用官方库文件)。
上github搜索phalcon,进入release页面 下载https://github.com/phalcon/cphalcon/tags?after=v3.4.5 下载3.4.4版本(本机是php7.2版本),并解压 kun@kundeMacBook-Pro phalcon_study % ls -l total 15720 dr-xr-xr-x@ 35 kun staff 1120 6 30 2019 cphalcon-3.4.4 -r-xr-xr-x@ 1 kun staff 6707840 12 3 23:53 cphalcon-3.4.4.tar.gz
进入cphalcon-3.4.4/ext目录先后执行phpize和configure命令
kun@kundeMacBook-Pro cphalcon-3.4.4 % cd build/php7/64bits kun@kundeMacBook-Pro ext % whereis phpize /usr/bin/phpize kun@kundeMacBook-Pro ~ % whereis php-config /usr/bin/php-config kun@kundeMacBook-Pro ext % ls -l /usr/bin/phpize lrwxr-xr-x 1 root wheel 33 12 8 10:58 /usr/bin/phpize -> /usr/local/opt/php@7.2/bin/phpize kun@kundeMacBook-Pro ext % /usr/local/opt/php@7.2/bin/phpize Configuring for: PHP Api Version: 20170718 Zend Module Api No: 20170718 Zend Extension Api No: 320170718 kun@kundeMacBook-Pro ext % ./configure -with-php-config=/usr/bin/php-config checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes ...省略打印 kun@kundeMacBook-Pro ~ % php --ini Configuration File (php.ini) Path: /usr/local/etc/php/7.2 Loaded Configuration File: /usr/local/etc/php/7.2/php.ini Scan for additional .ini files in: /usr/local/etc/php/7.2/conf.d Additional .ini files parsed: /usr/local/etc/php/7.2/conf.d/ext-opcache.ini kun@kundeMacBook-Pro ~ % vim /usr/local/etc/php/7.2/php.ini #新增扩展配置 extension=/usr/local/Cellar/php@7.2/7.2.34_1/pecl/20170718/phalcon.so extension=/usr/local/Cellar/php@7.2/7.2.34_1/pecl/20170718/phalcon.so #扩展打印 kun@kundeMacBook-Pro ~ % php --ri phalcon phalcon Web framework delivered as a C-extension for PHP phalcon => enabled Author => Phalcon Team and contributors Version => 3.4.4 Build Date => Dec 8 2020 11:23:01 Powered by Zephir => Version 0.10.16-6826149172 Directive => Local Value => Master Value phalcon.db.escape_identifiers => On => On phalcon.db.force_casting => Off => Off phalcon.orm.events => On => On phalcon.orm.virtual_foreign_keys => On => On phalcon.orm.column_renaming => On => On phalcon.orm.not_null_validations => On => On phalcon.orm.exception_on_failed_save => Off => Off phalcon.orm.enable_literals => On => On phalcon.orm.late_state_binding => Off => Off phalcon.orm.enable_implicit_joins => On => On phalcon.orm.cast_on_hydrate => Off => Off phalcon.orm.ignore_unknown_columns => Off => Off phalcon.orm.update_snapshot_on_save => On => On phalcon.orm.disable_assign_setters => Off => Off
到此phalcon扩展安装成功,接下来安装phalcon-devtools辅助扩展
进入下载页面,这里是php7.2下载3.4.9版本。 https://github.com/phalcon/phalcon-devtools/tags https://github.com/phalcon/phalcon-devtools/archive/v3.4.9.tar.gz 下载解压 kun@kundeMacBook-Pro phalcon-devtools-3.4.9 % cd ide kun@kundeMacBook-Pro ide % head -30 gen-stubs.php <?php /** * This scripts generates the stubs to be used on IDEs * * Specify CPHALCON_DIR env variable to point to the dev/ directory in the Phalcon source code * * *nix: CPHALCON_DIR=/path/to/cphalcon/ext/ php ide/gen-stubs.php * Win: set CPHALCON_DIR=C:\Path\To\cphalcon\ext\ php ide/gen-stubs.php * * Alternative stubs generation * * cd cphalcon * zephir stubs */ #手动新增编辑你的地址 define(‘CPHALCON_DIR‘ , ‘/Users/kun/www/phalcon_study/cphalcon-3.4.4/ext/‘); putenv(‘CPHALCON_DIR=/Users/kun/www/phalcon_study/cphalcon-3.4.4/ext/‘); #手动新增编辑你的地址
#创建phalcon命令软链 kun@kundeMacBook-Pro ide % sudo ln -s /Users/kun/www/phalcon_study/phalcon-devtools-3.4.9/phalcon /usr/bin/phalcon #生成php文件 kun@kundeMacBook-Pro ide % php gen-stubs.php #打印可见新增3.4.4目录 kun@kundeMacBook-Pro ide % ls -l total 48 dr-xr-xr-x 3 kun staff 96 12 8 11:31 3.4.4 -r-xr-xr-x@ 1 kun staff 9757 12 4 18:13 gen-stubs.php -r-xr-xr-x@ 1 kun staff 9575 12 4 17:18 gen-stubs.php.bak.12-04 dr-xr-xr-x@ 4 kun staff 128 12 8 2019 phpstorm
phpstorm配置phalcon-devtools
phpstorm->Preferences->tools->Commands Line Tool,点击+符号,填写路径
include Path一开始为空,需要自己点击下方+号添加,路径是php gen-stubs.php命令生成的3.4.4目录下phalcon目录。
好了,到现在系统支持phalcon扩展,phpstorm支持phalcon-devtools扩展了