1、使用yaf-cg工具生成源码
2、配置php.ini里的内容
3、nginx配置
https://github.com/laruence/yaf/tree/master/tools/cg
php yaf_cg Sample
#will generator folder "Sample" under output:
ls output/Sample/
/*
application/ conf/ index.php readme.txt
*/
2、配置php.ini里的内容
yaf.environ = dev #区分本地、和线上的(dev、test、product)
yaf.use_namespace = 1 #命名空间
yaf.use_spl_autoload = 0
yaf.lowcase_path = 1
3、nginx配置
server
{
listen 80;
server_name yaftest2.51talk.com;
index index.php ;
root /home/www/htdocs/yaftest2;
access_log /logs/nginxlogs/wechat.51talk.com.access.log main;
error_log /logs/nginxlogs/wechat.51talk.com.error.log;
if ( $http_host ~* "^i.yaftest.net" ) {
rewrite "^/(.*)" /api.php?$1 last;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.php?$
{
fastcgi_pass unix:/dev/shm/php.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
4、让yaf代码支持开启命名空间,运行hellow word
由于我们开启了命名空间,php.ini如下:
yaf.use_namespace = 1
生成代码中的类引用方式需要改变。
如:
$application = new Yaf_Application( APPLICATION_PATH . "/conf/application.ini");
#更改为:
$application = new \Yaf\Application( APPLICATION_PATH . "/conf/application.ini");
其它的更改,请参照:
https://
github.com/elad-yosifon/php-yaf-doc
建议将上面的php-yaf-doc下载下来放入本地的目录,这样phpstorm等编辑器,能找到相应方法。放入即可不要include或require它5、加载 composer网站根目录编辑composer.json键入:
然后运行:composer up
require部分是pdo链接数据库
将 conf/application.ini打开,增加 [dev : common]
增加的内容取决于你的php.ini:
yaf.environ = dev #区分本地、和线上的(dev、test、product)
建议将上面的php-yaf-doc下载下来放入本地的目录,这样phpstorm等编辑器,能找到相应方法。放入即可不要include或require它5、加载 composer网站根目录编辑composer.json键入:
{
"name": "lizhi-yaf/test-v1",
"autoload": {
"psr-4": {
"Api\\": "library/Api/",
"Cache\\": "library/Cache/",
"Components\\": "library/Components/"
}
},
"require": {
"lincanbin/PHP-PDO-MySQL-Class": "1.0.*"
}
}
然后运行:composer up
require部分是pdo链接数据库