Getting Started with the Phalcon PHP Framework

php

#1

This is a tutorial on installing and setting up the Phalcon PHP Framework on Cloud9. This is my first time creating a tutorial and also to use markdown, my apologies if the formatting could be better.

Installing Phalcon

sudo apt-add-repository ppa:phalcon/stable

sudo apt-get update

sudo apt-get install php5-phalcon

Note: You may see a note about a certain directory not being empty. You may ignore this and continue.

Installing Phalcon Developer Tools with Composer

  • Complete the following to install Phalcon Developer Tools via Composer (composer is pre-installed on this template)
  • Create composer.json with the following contents:
{
    "require": {
        "phalcon/devtools": "dev-master"
    }
}

Then from the terminal run:

composer install

Now we want to add the sym link so we can use the phalcon command globally.

sudo ln -s ~/workspace/vendor/phalcon/devtools/phalcon.php /usr/bin/phalcon

sudo chmod ugo+x /usr/bin/phalcon 

Now run phalcon to make sure everything above was done correctly. You should see a list of available phalcon commands.

Creating a Phalcon Project

  • Now we are going to create a project skeleton using the developer tools. For this example, our project name will be “cloudy”.
phalcon create-project cloudy

Now we need to update our virtual host so that we can see our project.

sudo nano /etc/apache2/sites-enabled/001-cloud9.conf

// Change this line
DocumentRoot /home/ubuntu/workspace

// To this
DocumentRoot /home/ubuntu/workspace/cloudy/public

Close the file with Control + X then press Y to save changes and Return to accept.

Run your project by clicking the “Run Project” button at the top of your workspace. You should now see a congratulations page.

  • Now we will setup the database using mysql that is preinstalled on this template.
mysql-ctl cli
use c9;
select @@hostname;
exit

Edit ~/workspace/cloudy/app/config/config.php with the database settings

    'database' => array(
        'adapter'     => 'Mysql',
        'host'        => 'localhost',
        'username'    => '(your c9 username)',
        'password'    => '',
        'dbname'      => 'c9',
        'charset'     => 'utf8',
    ),

Resources

Install Phalcon

Install Phalcon Developer Tools


Tutorials - Table of Contents