Install Phalcon PHP framework in Fedora

In my last article i discussed that how to install phalcon framework in openSUSE, and i guess it was quite fun and easy. Today i am extending the installation to Fedora. I installed it on Fedora 19, 20 and i hope there would be no problems for anyone, it will be quite simple and easy to install. As we know, we don’t have any repo or RPM at the moment for Fedora, so we will build it from source. Don’t worry it will not be scary. Read this for the dependencies 1st.

Fire up the terminal and i assume that you are in your home dir ([user@localhost ~]$). But no worries, you can change the dir to any where you want like your backup drive etc. Let’s go with home in this article. We need to clone the phalcon repository from github and create the extension from source.

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”3″ tab_size=”4″]
[user@localhost ~]$ git clone git://github.com/phalcon/cphalcon.git
[user@localhost ~]$ cd cphalcon/build
[user@localhost ~]$ sudo ./install
[/cc]

That will do the necessary for now, one last thing now. Open php.ini in terminal or whatever GUI editor you prefer(i will use vim):

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”1″ tab_size=”4″]
[user@localhost ~]$ sudo vim /etc/php.ini
[/cc]

And add this line:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”1″ tab_size=”4″]
extension=phalcon.so
[/cc]

Save and that’s it. Time to restart the server:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”1″ tab_size=”4″]
[user@localhost ~]$ sudo service httpd restart
[/cc]

Download any of the app from the phalcon repo like invo OR vokuro etc, and give it a try.

Enjoy!

Install Phalcon PHP framework in openSUSE

Phalcon is a web framework implemented as a C extension offering high performance and lower resource consumption”. From the benchmark page, “The compiled nature of Phalcon offers extraordinary performance that outperforms all other frameworks measured in these benchmarks”. Personally i find it very easy to work with, less dirs and files for the project. And it’s documentation is quite organized and useful. Installation in Linux distros is quite easy for most of the parts. Let’s install in openSUSE 12.3 and 13.1. 1st of all let’s thank Mariusz Łączak for his useful work to provide repositories. Fire up a terminal and become root by su – .

If you are on openSUSE 12.3, add this repo:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper ar -f http://download.opensuse.org/repositories/home:/mruz/openSUSE_12.3/ Phalcon

[/cc]

For openSUSE 13.1:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper ar -f http://download.opensuse.org/repositories/home:/mruz/openSUSE_13.1/ Phalcon

[/cc]

zypper-add-repo-phalcon

Refresh the repos:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper ref

[/cc]

It will ask for the key to trust for the new repo, just type a to trust always. We are almost there.

Before installation of phalcon, we need to make sure that these dependencies are installed: mbstring, mcrypt, opensll, pdo/MySQL

If not, no worries install it by using this command:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper in php5-mbstring mcrypt openssl php5-pdo

[/cc]

Time to install phalcon:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper in php5-phalcon

[/cc]

And that’s it, but before jumping to your web dir to start a demo project, restart apache:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

systemctl restart apache2.service

[/cc]

Phalcon documentation are self explanatory and easy to follow. Start here for a test project.

Install Nodejs in openSUSE 12.3

Nodejs is quite in news now a days and for good. Let’s not go to details here, straight to install process and get it working. The 1st thing is to fire a terminal and become root by su – . Let’s add a repository for the latest Nodejs packages, default openSUSE repos have Nodejs but old version (.8.12):

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper ar -f http://download.opensuse.org/repositories/home:/kwk:/orientdb/openSUSE_12.3/ Nodejs

[/cc]

After that refresh the repos:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper ref

[/cc]

And now installation time:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”4″ tab_size=”4″]

zypper install nodejs nodejs-devel

[/cc]

Latest Nodejs has npm packaged with it, so we should be good by installing Nodejs package.

And that should be it for now, keep checking i will write about how to use it and install some plugins, framework to work with.

How to install flash player in fedora 19

Installing flash player in fedora is quite easy. You only need to fire up the terminal and run few commands.

64bit arch:

sudo yum -y install http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm

32bit arch:

sudo yum -y install http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm

And now install it:

sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

sudo yum -y install flash-plugin

And that’s it.

How to install chromium browser in fedora 19

To install chromium browser in fedora you need to add a repo file to the yum.repos.d dir as it is not available in rpm fusion repos. So download the repo file from the link below:

https://repos.fedorapeople.org/repos/spot/

Right click on the fedora-chromium-stable.repo and save it to you hard drive by selecting “Save Link As”.

Now open terminal and cd to the location/dir where you downloaded the file. After that run this command:

sudo cp fedora-chromium-stable.repo /etc/yum.repos.d

And now time to install it:

sudo yum -y install chromium

And that’s it.

 

Pull pages data via facebook graph

In the last article we discussed how to create or extend access token for facebook pages. Today we are going a bit further and writing a script where we can pull some pages data.
So here is the full code, i will explain it below where necessary.

Save the following code as index.php(or whatever name you like).
[cc lang=”php” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”80″ tab_size=”4″]
<?php
// Facebook APP [Pages App for access tokens]
define(‘APP_ID’, ‘enter_app_id_here’);
define(‘APP_SEC_KEY’, ‘enter_app_secret_here’);

// Access Token
define(‘ACCESS_TOKEN_PAGE1’, ‘enter_access_token_here_for_page1’);
define(‘ACCESS_TOKEN_PAGE2’, ‘enter_access_token_here_for_page2’);

// Page IDs
define(‘APP_PAGE_ID_PAGE1’, ‘enter_page1_id_here’); // for page1
define(‘APP_PAGE_ID_PAGE2’, ‘enter_page2_id_here’); // for page2

// Create array for pages ids, tokens, country etc
$total_pages = array( array( ‘Pageid’ => APP_PAGE_ID_PAGE1, ‘Access_token’ => ACCESS_TOKEN_PAGE1, ‘Country’ => ‘FINLAND’ ), array( ‘Pageid’ => APP_PAGE_ID_PAGE2, ‘Access_token’ => ACCESS_TOKEN_PAGE2, ‘Country’ => ‘SINGAPORE’ ) );

// periods
$day = ‘day’;
$week = ‘week’;

$date = date(“10-07-2013”);

foreach ($total_pages as $pages) {

$pageid = $pages[‘Pageid’];
$accesstoken = $pages[‘Access_token’];
$country = $pages[‘Country’];

// Daily People Talking About This [page_storytellers]
$fql_query_page_storytellers = ‘https://graph.facebook.com/’.’fql?q=SELECT+metric,value+FROM+insights+WHERE+object_id=’.$pageid.’+

AND+metric=”page_storytellers”+AND+end_time=end_time_date(“‘.$date.'”)+

AND+period=period(“‘.$day.'”)&access_token=’.$accesstoken;

$fql_obj_page_storytellers = file_get_contents($fql_query_page_storytellers, true);

//print_r($fql_obj_page_storytellers);
if(!empty($fql_obj_page_storytellers[‘data’])) {
echo $e1 = $fql_obj_page_storytellers[‘data’][‘0’][‘value’];
}
else
{
echo $e1 = “empty string”;
}

// Daily New Likes [page_fan_adds_unique]
$fql_query_page_fan_adds_unique = ‘https://graph.facebook.com/’.’fql?q=SELECT+metric,value+FROM+insights+WHERE+object_id=’.$pageid.’+

AND+metric=”page_fan_adds_unique”+AND+end_time=end_time_date(“‘.$date.'”)+

AND+period=period(“‘.$day.'”)&access_token=’.$accesstoken;

$fql_obj_page_fan_adds_unique = file_get_contents($fql_query_page_fan_adds_unique, true);

//print_r($fql_obj_page_fan_adds_unique);
if(!empty($fql_obj_page_fan_adds_unique[‘data’])) {
echo $e2 = $fql_obj_page_fan_adds_unique[‘data’][‘0’][‘value’];
}
else
{
echo $e2 = “empty string”;
}

}
?>
[/cc]

———————————————————–

PLEASE READ BEFORE USING THE SCRIPT

From the above script change the following vars:

enter_app_id_here = change this to your app id which you created.

enter_app_secret_here = enter the app secret here.

enter_access_token_here_for_page1 = enter the access token for page 1 if you have many pages.

enter_access_token_here_for_page2 = enter the access token for page 2 if you have many pages.

Note: You can add many pages as you want, but if you have only one page, just remove the 2nd array from the $total_pages array for page2. I have added country var to the array, this is only to recognize the data if have many pages while easy to save to database for later use.

enter_page1_id_here = You can get this while following the previous article.

enter_page2_id_here = You can get this while following the previous article.

For the periods, please read the facebook insight page for more details and usage.

There are not much changes required except from the above. But if you want to change the script for your need, go ahead and change/enhance it as it fits your requirements. You can pull more data by reading the insight page OR can save the data to database for later use.

———————————————————–

Open your browser and call index.php. One more thing, facebook does not provide latest data for pages so you have to go back last 3 days, if today is 14-07-2013, you can get the data for 10-07-2013 or maybe 11-07-2013.