Học lập trình web PHP trực tuyến

In this tutorial, I list step by step how to install Phalcon Devtool on Mountain Lion 10.8.x. Phalcon is a web framework implemented as a C extension offering high performance and lower resource consumption framework. Like Ruby On Rails, developer has a tool to generate code scaffold faster (Don’t repeat yourself), Phalcon Devtool helps developer to generate code that uses Phalcon framework.

See original instruction here. The problem is when I follow this instruction, it does not work very well. So here is what I have done:

1-Get source code of Phalcon-Devtools

cd ~
git clone https://github.com/phalcon/phalcon-devtools.git

2-Try to run Dev-Tools ~/phalcon-devtools/phalcon.php

Notes: You need to make sure PHP CLI is installed in Mountain Lion by type
php –version
The result looks like this
PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

There are two possibilities:
A> ~/phalcon-devtools/phalcon.php runs successfully. Then you should see something likes “Phalcon DevTools (1.2.1)”
B> ERROR: Phalcon extension isn’t installed, follow these instructions to install it: http://docs.phalconphp.com/en/latest/reference/install.html

To fix B> you need to install Phalcon extension on Mac.

cd ~
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install

If success, phalcon.so will be installed into the folder /usr/lib/php/extensions/no-debug-non-zts-20090626.
Edit php.ini of PHP CLI to add phalcon.so

php -i | grep 'Configuration'
sudo nano /private/etc/php.ini

add this line extension=phalcon.so to php.ini

After you enable phalcon.so in PHP CLI, you should be able to run ~/phalcon-devtools/phalcon.php

To make life easier, you can make symbolic link of phalcon.php script to /usr/bin/phalcon by

sudo ln -s ~/phalcon-devtools/phalcon.php /usr/bin/phalcon
chmod ugo+x /usr/bin/phalcon

From now you can type phalcon every where to run Phalcon-Devtools.
See this video to make a poll in Phalcon within 15 minutes

By cuong(at)techmaster.vn