linux版本为CentOS6.5
安装必须的工具
yum install php-devel pcre-devel gcc make
安装git
yum install git
git到新版本的phalcon,并且编译安装
git clone --depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install
安装Notes
在httpd.conf中修改你的主目录为/var/www/test
添加
<IfModule mod_rewrite.c>
<Directory "/var/www/test">
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</Directory>
<Directory "/var/www/test/public">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</Directory>
</IfModule>
在test下搭建自己的一个测试工程
结构如下
test/
app/
controllers/
models/
views/
public/
css/
img/
js/
index.php
index.php内容
<?php try { //Register an autoloader $loader = new \Phalcon\Loader(); $loader->registerDirs(array( ’../app/controllers/’, ’../app/models/’ ))->register(); //Create a DI $di = new Phalcon\DI\FactoryDefault(); //Setup the view component $di->set(’view’, function(){ $view = new \Phalcon\Mvc\View(); $view->setViewsDir(’../app/views/’); return $view; }); //Setup a base URI so that all generated URIs include the "tutorial" folder $di->set(’url’, function(){ $url = new \Phalcon\Mvc\Url(); $url->setBaseUri(’/tutorial/’); return $url; }); //Handle the request $application = new \Phalcon\Mvc\Application($di); echo $application->handle()->getContent(); } catch(\Phalcon\Exception $e) { echo "PhalconException: ", $e->getMessage(); }
8.添加一个controller
<?php class IndexController extends \Phalcon\Mvc\Controller { public function indexAction() { echo "<h1>Hello!</h1>"; } }
页面会显示一个hello!
搭建成功