mac安装phalcon

mac安装phalcon中文文档中文文档2

brew1.5.0之前安装phalcon

brew install homebrew/php/php71-phalcon

检测是否安装成功

php -i |grep phalcon
Additional .ini files parsed => /usr/local/etc/php/7.1/conf.d/ext-phalcon.ini,
phalcon
phalcon => enabled
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.column_renaming => On => On
phalcon.orm.disable_assign_setters => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.enable_literals => On => On
phalcon.orm.events => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.not_null_validations => On => On
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.virtual_foreign_keys => On => On

brew1.5.0之后取消了php71-phalcon分支,需要自己编译文档

Libraries have been installed in:
   /usr/local/src/cphalcon/build/php7/64bits/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/Cellar/php/7.2.4/pecl/20170718/
Installing header files:          /usr/local/Cellar/php/7.2.4/include/php/

Thanks for compiling Phalcon!
Build succeed: Please restart your web server to complete the installation

后面的编译看这篇文章

安装phalcon/devtools

这里我个人建议使用composer安装

composer global require "phalcon/devtools"

创建phalcon软连

这里我软连接到/usr/bin/phalcon

ln -s ~/.composer/vendor/phalcon/devtools/phalcon.php /usr/bin/phalcon
出现报错
ln: /usr/bin/phalcon: Operation not permitted

这是因为苹果在OS X 10.11中引入的SIP特性使得即使加了sudo(也就是具有root权限)也无法修改系统级的目录,其中就包括了/usr/bin。要解决这个问题有两种做法:一种是比较不安全的就是关闭SIP,也就是rootless特性;另一种是将本要链接到/usr/bin下的改链接到/usr/local/bin下就好了。

ln -s ~/.composer/vendor/phalcon/devtools/phalcon.php /usr/local/bin/phalcon

测试是否安装成功

phalcon

Phalcon DevTools (3.2.12)

Available commands:
  info             (alias of: i)
  commands         (alias of: list, enumerate)
  controller       (alias of: create-controller)
  module           (alias of: create-module)
  model            (alias of: create-model)
  all-models       (alias of: create-all-models)
  project          (alias of: create-project)
  scaffold         (alias of: create-scaffold)
  migration        (alias of: create-migration)
  webtools         (alias of: create-webtools)
  serve            (alias of: server)
  console          (alias of: shell, psysh)

安装phpstorm ide插件phalcon-auto-complete

新建项目

phalcon project phalcon --type modules

因为我这用的valet在开发,所以,设置虚拟主机很简单

cd phalcon/
valet link phalcon

遇到的问题

Mod-Rewrite is not enabled

valet设置虚拟主机后,访问 phalcon.test 遇到需要开启重写模块

Mod-Rewrite is not enabled
Please enable rewrite module on your web server to continue
解决办法

因为phalcon和laravel不一样,所以不能在phalcon/目录下直接link,直接到public下link

cd phalcon/public
valet link phalcon

Class 'Phalcon\Di\FactoryDefault' not found这里有解答方案

其实意思就是说.是说phalcon.so没加载


Fatal error: Uncaught Error: Class 'Phalcon\Di\FactoryDefault' not found in /Users/ailuoy/code/learning/phalcon/app/bootstrap_web.php:17 Stack trace: #0 /Users/ailuoy/code/learning/phalcon/public/index.php(2): require() #1 /Users/ailuoy/.composer/vendor/laravel/valet/server.php(133): require('/Users/ailuoy/c...') #2 {main} thrown in /Users/ailuoy/code/learning/phalcon/app/bootstrap_web.php on line 17
phpinfo(),查看扩展是否加载

我看了下,确实是未加载的,但是这里我是homebrew安装的扩展啊,应该不用在php.ini中去写extension=phalcon.so

所以..我就直接重启了php-fpm,因为我是valet,所以就

valet restart
检查扩展是否加载

太棒了...扩展加载成功,那么我们就看是否能访问到

file

检查是否能访问到

OK!! 大功告成!!

Congratulations!
You're now flying with Phalcon. Great things are about to happen!

This page is located at views/index/index.phtml