mac下搭建phalcon擴展以及phalcon-devtools擴展

最近安裝phalcon擴展遇到一點坑,這裏回顧記錄下,避免再次踩坑。php

 

若是使用引擎搜索phalcon關鍵字最初的幾條搜索結果,點擊進去使用的均不是官方的phalcon擴展。git

這裏不用非官方的phalcon庫(之後安裝別的什麼軟件最好都用官方庫文件)。github

上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命令vim

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

進入下載頁面,這裏是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-devtoolsphpstorm

phpstorm->Preferences->tools->Commands Line Tool,點擊+符號,填寫路徑ide

 

 

 

include Path一開始爲空,須要本身點擊下方+號添加,路徑是php gen-stubs.php命令生成的3.4.4目錄下phalcon目錄。ui

 

好了,到如今系統支持phalcon擴展,phpstorm支持phalcon-devtools擴展了spa

相關文章
相關標籤/搜索