什么是Phalcon? 是框架,最快!为什么快?因为他的本质是用C语言写的。C语言是所有其他语言他妈。呈现方式是dll,或者so文件。
php的关键文件及目录
/
/ext extension php的扩展组件存放目录
/php.exe php的可执行文件
/php.ini php的配置文件
是不是所有的 ext 目录下 的组件都被php加载了?不是,具体加载了哪些,由/php.ini 决定,如何查看加载了哪些模块?
- 直接去看php.ini
- phpinfo()
- php-m (在cli模式下)
- 注:ini文件也是有注释的,用 ; 表示注释
php.ini关键配置
- extension_dlr:指示php的扩展目录
- extension:指定加载组件
综上。Phalcon的加载是通过修改php.ini 加载到php扩展中的,不像那些庸脂俗粉,还得用大量的文件。
如何安装phalcon
下载php的扩展
需要特别强调,从4版本开始,phalcon需要psr扩展支持,所以在开启phalcon扩展前,需要提前开启psr
- ts thead safety 线程安全
- nts not thread safety 非线程安全
选择dll文件的时候,需要与phpinfo中的thread safety 对应。disable 表示非线程安全。
| Thread Safety | disabled |
|---|
配置php.ini
[psr]
extension=php_psr.dll
[phalcon]
extension=php_phalcon.dll
如何新建一个phalcon项目
通过官网的phalcon-devtools工具
phalcon project [项目名称]
如何安装phalcon-devtools
下载源码
https://github.com/phalcon 官网开源主页
dev-tools下载地址
运行 composer install
将目录添加到系统变量
只有这样才能随处运行phalcon
创建项目
D:\data\wwwroot
$ phalcon
Phalcon DevTools (4.1.2)
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)
D:\data\wwwroot
$ phalcon project
Phalcon DevTools (4.1.2)
Help:
Creates a project
Usage:
project [name] [type] [directory] [enable-webtools] [force]
Arguments:
help Shows this help text
Example
phalcon project store simple
Options:
--name=s Name of the new project
--enable-webtools Determines if webtools should be enabled [optional]
--directory=s Base path on which project will be created [optional]
--type=s Type of the application to be generated (cli, micro, simple, modules)
--template-path=s Specify a template path [optional]
--template-engine=s Define the template engine, default phtml (phtml, volt) [optional]
--use-config-ini Use a ini file as configuration file [optional]
--trace Shows the trace of the framework in case of exception [optional]
--force Creates project even if directory already exists [optional]
--help Shows this help [optional]
可能遇到的错误
Mod-Rewrite is not enabled
Please enable rewrite module on your web server to continue
官方推荐的重写规则
location / {
# Matches URLS `$_GET['_url']`
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
根目录要调整为 /public
注:config目录只是友好的约定了一下,什么文件,应该被放在什么位置。并没有真正的被加载到内存中。
真正加载,是由loader来完成。
英语
be about to do sth. 要发生什么事情。
Comments