Categories: PHP

Framework: Phalcon

Table of Contents

Framework: Phalcon

You all must have heard about Phalcon framework many times and many of you may not know what it is? So today’s topic of our article is “Phalcon”

 

We will discuss the Phalcon framework and also try to build some project with it, just for practice. We will access phalconphp.com website and will try to get some information through it.

Phalcon is the best framework I have ever used in PHP. It is the fastest fully featured framework. If you log in to phalconphp.com, and if you look at its benchmarks you will also come to know that the CodeIgniter framework is still pretty fast but Phalcon is far better than it.

But you know Phalcon is an actual PHP extension so it’s ridiculously fast. Meaning you don’t have to load multiphp libraries when you use it. It’s loaded in memory.
So! basically its an MVC framework and it has an ORM for Mongo too. But ORM is actually very nice. They either used and they have some documentation and go down a little bit on this same screen to Let’s learn by Example and this is a pretty good series to get started to check it out.

Then they also have an application called INVO which you can download from the GitHub. If we go to the Docs menu, under it you will find GitHub Project, if we go here you can get the code from GitHub, this is what you find in this tutorial explaining INVO.
If we click to download it then they have Linux/Unix/Mac installations. In Windows, we can drop DLL’s inside the extensions folder and as the extension, My PHP INI is very easy.

For Linux it’s also easy, you need php5-dev package. You can use Debian to switch from CentOS to Debian. Ubuntu is also pretty good. CentOS and Debian are Pretty good.
You need php5-dev package because you need to compile the add-on and it takes about 5 minutes and then obviously the GCC libraries. This is how you clone it using git and you can use the following command to create the extension from c source
git-clone git://github.com/phalcon/cphalcon.git

 

You might have to install using the above step. It comes with Ubuntu and Debian as well by default. After you clone it, go into the directory do -/install and then you add the extension to your php.ini file which will be under /etc/php5 and restart your server and you are good to go.

If you are installing it on Mac then it is a little bit different. Actually asked on the Forums.
So lets login with GitHub search for Mac here you will see the results and you can do it using few steps. On Mac, it’s too expensive so not usually installed on Mac. There you will find various threads for installing.

It’s not very easy to install, on Windows it took around 30 seconds, on Linux it took 2 minutes to complete compile but depending on your server it would determine the speed.
But it is really good. It makes your programs really small. You don’t even have a framework to loaded in your folder. Its just loaded in the PHP memory.

The favorite thing is ORM- It’s just so clean and classy and nice. I am just surprised, this is the most popular working with models. If you ever use Django, basically you create a class in this representation of the database table. So if you have a Robots table and if you wanted the Robots to refer some different tables – here you will just say get source and return, “ the-robots” if MySQL table is Robots.

The documentation is wonderful. There is so much of it. Just browse it they have a nice little EER diagram if you use ORM but it takes a lot of time. So in some example the Robots has many robot-parts and based on the id of the Robots table the robot-parts, robots-id knows too many tables.

You know it is a little bit information around it. It’s really very nice. Now you can just check out robots, they can look through all the parts and through the associated table.

You can build a directory structure, the way you want and you can also load the bootstrap with whatever you want in it.

They have a bootstrap documentation, there is the public/index.php file for registering your directories and any dependency loading you can also see DI which is Dependency Director.

Just set in your views there and you don’t really have to set them up once you set up

MySQL connection and everything.
Once that’s configured handle the request. The handle method gets the route and knows the proper controller.

If you are coming from say CodeIgniter or Laravel or something the controllers is pretty much the same its a little bit like an end with the word action.

Controller – Create a Controller. What’s cool about it is that it has a pattern which it follows which you can turn off if you like but if I have a controllers folder, models and views folder then I would have a public folder this is how they like to design the layout.
But you can do it in any way you want.

So the public folder would have a bootstrap file, this is where vhost would point to just a /public folder.
This will basically load up all the necessary things.
/app/
/controllers/
/models/
/views/
/public/
index.php(bootstrap) <— vhost will point to /public/

 

 

Visit: Hostripples
WordPress Web Hosting

 


Vishwajit Kale
Vishwajit Kale blazed onto the digital marketing scene back in 2015 and is the digital marketing strategist of Hostripples, a company that aims to provide affordable web hosting solutions. Vishwajit is experienced in digital and content marketing along with SEO. He's fond of writing technology blogs, traveling and reading.

Recent Posts

Crafting a Professional Email: Step-by-Step Guide

Due to growing digitalization, Email Communication has become the backbone of professional interactions. Yet, surprisingly, many professionals struggle to craft…

1 day ago

Demystifying SSL: What Every Website Owner Should Know

As the digital landscape continues to evolve, securing your website has never been more crucial. SSL, or Secure Sockets Layer,…

1 week ago

Cyberduck and FileZilla: A Comprehensive Comparison

As a web designer and web developer your experience must have reached to new height, right? Further, you need to…

1 month ago

The Science Behind Social Media Posting Times

In today's digital landscape, timing is everything. Whether you're a social media manager, business owner, or content creator, the success…

1 month ago

Mastering Google Search Console: Tips for New Users

Are you a website owner? Maintaining the website is the prime concern for any website owner. Yes, it’s equally important…

1 month ago