INSTALL AND SETUP PHALCON 3.3 ON UBUNTU 18.04.1 LTS

Phalcon is a PHP web framework based on the model–view–controller pattern. Its innovative architecture makes Phalcon the fastest PHP framework ever built.

It is lightweight, fast, minimal, flexible and good for projects of all sizes. Like many other platforms, Phalcon PHP also offers the range of benefits and features for the developer. Another awesome thing about Phalcon is Zephir. With it, you can now write PHP extensions pretty much in PHP (used to be in C). Phalcon itself is written in Zephir.

Phalcon got famous due to its superb performance features. Further, a range of features including object relation management, Phalcon PHP query Language, Object Document Mapper, Transactions, Cache, Flash Messages, Form Builder, i18n, Volt, Template engines, Queuing, Events, Crypt, Sharding, ACL etc make it the best.

In this guide, we will go over the steps you need to take to install and setup Phalcon 3.3 on your Ubuntu system.



 

SETTING PHALCON

1. INSTALL APACHE2

Phalcon requires a web server to run. The popular web servers today are, Apache2 and NGINX. In this guide, we are using Apache2. You can install Apache2 with the below command.

sudo apt-get install apache2

2. INSTALL PHP AND IT’S EXTENSIONS

Since Phalcon is a PHP framework, PHP and some of its extensions need to be installed before setting up Phalcon.

sudo apt-get install php php-curl php-gettext php-json php-json php-mbstring php-pdo_* php-fileinfo

Sudo apt-get install openssl libpcre3-dev

3. INSTALL MYSQL

Phalcon also requires a database server. The most using database with php is Mysql. It can be installed with the commands below.

sudo apt-get install mysql-server mysql-client

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

Enter current password for root (enter for none): (Press Enter)
Set root password? [Y/n]: Y
New password: (Enter the password for MySQL DB)
Re-enter new password: (Repeat password)
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

 

In the latest version of MySQL, it rollbacks the support for the root user. So, you can not migrate the database with root user. So that we need to create a new user and grant all privileges to the user.

 

sudo mysql --user=root mysql

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

EXIT;

4. INSTALL PHPMYADMIN

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySql over the Web. Phpmyadmin enables you the use of GUI over MySql. It can be installed using the command below.

sudo apt-get install phpmyadmin

It will ask for your MySQL credentials and you have to give it properly.



5. INSTALL PHALCON

Now it’s time to install Phalcon using Advanced Packaging Tool(APT) of Ubuntu.

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install php-phalcon

6. INSTALL PHALCON-DEVTOOLS

This tool provides useful scripts to generate code helping to develop faster and easy applications that use with Phalcon framework. You can clone it from Github easily.

 

git clone git://github.com/phalcon/phalcon-devtools.git

cd phalcon-devtools/
. ./phalcon.sh

 

Create a symbolic link to the phalcon.php script:

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

sudo chmod ugo+x /usr/bin/phalcon

7. CREATING NEW PHALCON APP

New Phalcon app can be created using the command,

phalcon create-project AwesomeProject

8. RUNNING YOUR PHALCON APP

Now On your browser, enter

http://[ YOUR_IP_ADDRESS ]/[project_directory]

And this will lead you to the home page of Phalcon application you have created.



9. CREATE VIRTUALHOST IN APACHE SERVER

To serve your app directly to a connected domain, you have to add the lines below to your /etc/apache2/sites-enabled file.

<VirtualHost *:80>
        ServerAdmin webmaster@example.com
        ServerName phalcon.example.com
        DocumentRoot /var/www/AwesomeProject/public
        <Directory /var/www/AwesomeProject/>
            Options all
            AllowOverride all
        </Directory>
</VirtualHost>

Have a nice code!

Be the first to reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.