mac下搭建phalcon擴充套件以及phalcon-devtools擴充套件
阿新 • • 發佈:2020-12-08
最近安裝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@ 35kun 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一開始為空,需要自己點選下方+號新增,路徑是phpgen-stubs.php命令生成的3.4.4目錄下phalcon目錄。
好了,到現在系統支援phalcon擴充套件,phpstorm支援phalcon-devtools擴充套件了