Saturday, October 13, 2012

How to make user login with Google Account in your site

In many sites you might have noticed that, there are many options for login. Means to login into that site you can use Google, Yahoo, AOL etc. accounts.

You can integrate Google account for your site very easily. To make this we'll use OpenID.  OpenID provides a safe, elegant and easy way for people to login into your website without having to fill in a registration form. They just have to have an account to one OpenID provider, a Google account for instance, and they will login into your site with this account.



dI'll show you how to implement it with Google Account.

1.) We'll be using a one-file PHP OpenID library that you can download from here. LightOpenID. Just put this file in your project folder.

2.) Now, Here is login.php


< ?php
require_once 'openid.php';
$openid = new LightOpenID("my-domain.com");
 
if ($openid->mode) {
    if ($openid->mode == 'cancel') {
        echo "User has canceled authentication !";
    } elseif($openid->validate()) {
        $data = $openid->getAttributes();
        $email = $data['contact/email'];
        $first = $data['namePerson/first'];
        echo "Identity : $openid->identity ";
        echo "Email : $email";
        echo "First name : $first";
    } else {
        echo "The user has not logged in";
    }
} else {
    echo "Go to index page to log in.";
}
?>

    Note : Replace "myp-domain.com" with your site url.


3.) Now, final step to render the button, let's say on the home page. "index.php"

< ?php
require_once 'openid.php';
$openid = new LightOpenID("my-domain.com");
 
$openid->identity = 'https://www.google.com/accounts/o8/id';
$openid->required = array(
  'namePerson/first',
  'namePerson/last',
  'contact/email',
);
$openid->returnUrl = 'http://my-domain.com/login.php'
?>
 
<a href="< ?php echo $openid->authUrl() ?>">Login with Google





4.) To logout a user,  just destroy  the session.

session_destroy();



Other OpenID providers:

  • Google : https://www.google.com/accounts/o8/id
  • Yahoo  : https://me.yahoo.com
  • AOL    : https://www.aol.com


You can download full demo project from here.

Analysis :








Tuesday, October 9, 2012

Getting Started : Integrate ZF with NetBeans IDE

Now, you are ready with zend framework installation in your computer. So, let's integrate ZF with NetBeanse IDE.

Open your NetBeans IDE and active PHP Plugin module in you IDE and then follow these steps :

Step : 1




-> As shown in this figure. Open Options  from Tools menu. and open PHP  -> Zend tab.  Then press search box highlighted in image.

-> It'll open box like above image. It'll search for zf.sh (for Linux), zf.bat (for windows), select zf.sh and press OK.
->Now, press register provider and hit OK.
-> Now, goto "General" tab on PHP option.

-> Then Press "OK".

That's it. You have successfully integrated, Zend Framework with NetBeans IDE.


Note : If you have problem for steps for integration I've uploaded it's video tutorial, so, it'll be more clearer to you.

Link of video in YouTube

Monday, October 8, 2012

Getting Started : Zend Framework Installation

Before get into zend framework project, let's understand a few things about ZF.
The core of ZF is a loosely  coupled application framework that consists  of a library of components.

These components are well written in object-oriented PHP. They can be used independently. It means that, you need to include those libraries which are required for your project, not to include all library of ZF.

Install Zend Framework

--> For Windows :

  1. Download latest ZF from official site of Zend Framework.
  2. extract that folder.  "ZendFramework-1.11.11-minimal"
  3. open file in command tool,
  4. cd ZendFramework-1.11.11-minimal / bin / zf.bat
  5. type : zf --help


--> For Linux (Fedora) :

  1. login as a root user from terminal.
  2. Type These all commands :  "rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm"
  3. rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
  4. yum --enablerepo=remi install php-ZendFramework
  5. type : zf --help
That's it. Zend Framework environment is on your personal server.




Now, In next tutorial I'll explain you, how to create project with ZF on NetBeans.


Sunday, October 7, 2012

Zend Framework tutorial for beginner

After a long pause, I'm back with new tutorials, about Zend Framework.

Who This Tutorial Is For,
These tutorials are for PHP programmers who have at least some experience working with object-oriented programming. It would help to have some familiarity with Zend Framework, but you'll learn a lot about the framework over the course of tutorials.

Prerequisites,
To follow along with the examples, you will need a computer on which you can install a local testing zend server. I've used Fedora Linux server. Use NetBeans  as IDE or any other editor you like.

Why Zend Framework ?

The Zend Framework is really a hybrid framework and as such can be used in a much larger range of projects than strict “application frameworks”. While many components in Zend Framework can be used stand-alone like a component library; it is, at its core an implementation of the “Model-View-Controller” (MVC) pattern.

In a nutshell, the Zend Framework introduces a standardized set of components that allow for easy development of web applications. These applications can be easily developed, maintained and enhanced.

The key features of the Zend Framework are:
  • Everything in the box
  • Modern design
  • Easy to learn
  • Full documentation
  • Simpler Development
  • Rapid development

The Zend framework can be divided into 10 main modules.






























How Zend MVC works ?

In this figure, I've shown that, how MVC structure is working for site to make it meaningful.

Which framework is best for you ?

List of most popular frameworks :

There are many other frameworks available, but these are most widely adopted by developers.

Each of these frameworks is built in PHP language, but they differ in their methods and libraries.


Each of these frameworks has been released as open source projects, which means that a lot of development work relies on community support. Tracking bugs, writing supporting documentations, and providing general support are tasks that involve developers like you.




ZEND FRAMEWORK

Zend Framework was arguably the first framework to be built for PHP. Its corporate sponsor, Zend Technologies, has a long history with the PHP language itself; its founders include two of the original authors of PHP, Andi Gutmans and Zeev Suraski. Much of what has made PHP one of the most popular web programming languages started with Zend Technologies and its contributions to the language. That being said, no wonder Zend Framework has had early success and continues to be a major player in the PHP frameworks market.

In terms of community support, Zend Framework has probably the largest online following of any of the PHP frameworks. Its documentation is extensive and thorough, and unofficial blogs and forums make it possible to get online support for just about any question. Code submissions to the core are passed through rigorous testing methods, which makes Zend Framework an incredibly robust framework. However, Zend Framework is much more of a large set of libraries than a lightweight MVC framework. For instance, its main library folder is almost 16MB, more than three times the size of Cake’s libraries. Getting Zend Framework off the ground requires much more customization and configuration, whereas Cake has adopted more of the “convention over configuration” paradigm. You could likely use Zend Framework with just about any PHP project, which I'll demonstrate in   tutorials.

Zend Framework has no single development paradigm like Cake, CodeIgniter, and
Symfony, and that appeals to many developers. Patterns like MVC are therefore possible in Zend Framework, but these require you to manually write configuration methods, which are automatically built into Cake and other frameworks. Cake is certainly ahead of Zend Framework in how the framework cuts down the amount of code needed to extend it. Learning Zend Framework is generally more time-consuming than learning Cake, mostly because of the design of the framework. Getting an MVC variant of Zend Framework off the ground is usually more difficult for a beginner than Symfony, not to mention Cake.

True, Zend Framework is more well known than Cake in most PHP circles; it’s the veteran on the team, if you will. But Cake is proving to be more like the rising star that moves faster and is strategically sounder. Given Cake’s effective implementation of the MVC structure and its structural design, it will likely continue to attract former Zend Framework developers and remain the top player in the PHP frameworks arena.



CODEIGNITER


CodeIgniter’s community is relatively small when compared to CakePHP but does have a good support network online. Its user guide (www.codeigniter.com/user_guide) is well designed and has a nice layout for navigating through the table of contents. Many of the concepts used by Cake are also used by CodeIgniter, such as the MVC structure, helpers, routing, scaffolding, and caching. The support network is great, with a forum that boasts more than 66,000 topics and more than 400,000 posts. However, a lot of the topics there aren’t directly related to code development issues like Cake’s discussion group. In a sense, CodeIgniter’s forums and wiki are more like combining Cake’s discussion group, Bakery, and CakeForge. The number of websites built on CodeIgniter is smaller than that for Cake, but CodeIgniter is off to a good start and will likely become a more popular framework in the future.


Starting a CodeIgniter application takes less time than setting up a Cake application; however, some configuration methods that come preinstalled with Cake are left out with CodeIgniter. For example, setting up routes to behave like they do in Cake will require that you manually write an .htaccess file to pass paths through a similar routing engine. By default, CodeIgniter is more lightweight than Cake, which is one of its chief selling points. However, as you expand your CodeIgniter application, expect to have to perform an extra step here or there to achieve the same functionality you get from Cake.


The MVC structure in CodeIgniter is similar to Cake’s. Because of this, the general process of creating models, views, and controllers is nearly identical to what you learn when building Cake applications. Aside from minor differences in passing data around the application and naming conventions, running CodeIgniter is largely the same experience as in Cake. However, where Cake wins is with its powerful core classes, helpers, routes, and data-handling methods. The available resources and built-in functionality are more robust in Cake and, frankly, more cohesive. In other words, Cake developers will probably think they have taken a step backward when fully immersing themselves in CodeIgniter, though they will undoubtedly think they are in familiar territory. That’s not to say that CodeIgniter isn’t already a fabulous framework; it’s just that it separates methods into its several resources less effectively than Cake. In a nutshell, the Cake paradigm is more about making the model fat and spreading out the various methods; CodeIgniter makes for very large controllers.


SYMFONY

Symfony entered the PHP frameworks arena early on and has remained popular. Its community is also large with developers groups, forums, a chat room, a wiki, and more. All of the main links to these various online groups and sites are available on Symfony’s community web page (www.symfony-project.com/community).


After you have successfully begun a Symfony application, you will need to initialize your data source connections using the command line as well as perform other setup tasks. Generating the scaffolding is also done in the console, but the final result is similar to Cake’s scaffolding. Building models is primarily done using YAML-based configurations together with the symfony console script. If you prefer YAML to JSON or XML for configuring your database schema, then Symfony will probably suit you well. Cake really doesn’t compare in this regard because its methods for connecting to a data source don’t involve the command line (even though you can use Bake to write your database.php configuration file and build models).

When extending the Symfony application to take on more methods, many of the same concepts that make Cake effective are used. The learning curve is steeper when going from Cake to Symfony, mainly because the benefits Symfony offers are usually found in its command-line interface. However, Symfony users shouldn’t find learning Cake all that difficult. It may take some getting used to running fewer commands in the console, but on the whole, you shouldn’t have to perform any more steps to build your Cake applications than you would expect for a Symfony application.




CAKEPHP

Duplication throughout the community is kept to a minimum, so expect to be directed to a thread or blog post that someone has already used to address the same topic when asking a question or requesting support. You will also probably sense a feeling of perfectionism in the community. What I mean by that is this—the Cake Software Foundation, which manages Cake’s development, could have easily taken shortcuts when developing the framework. Compared to other frameworks, Cake would already be considered a version 3.0 or 4.0, but it’s currently at 1.2. This is due more to really tightening up the framework rather than cooking up something fast that could perform a large plethora of methods. The result of this strategy is that Cake really is more robust, mature, and well written than it otherwise would be, and you can count on it maintaining its robustness as it takes on more fancy methods.



Then "Which framework is right for me ?"

In each framework, you might notice powerful features than other framework, but selection of framework is always depends on which type of project you want to develop. Because, every framework has its own power to drive a site properly. In all framework powered sites, 60-65% site powered by Zend Framework, because of its beautiful and awesomeness.

To answer the question fully though, we really have to examine why we use a framework. Aside from the “two choices” scenario described above, programmers use a framework to simplify application development by providing much of the common code. A good framework will also enforce some structure on the code. However,  be wary of any framework that enforces rigid style conventions that you do not already adhere to. Your chosen framework should be flexible enough to adapt to the style and needs of your project.


The ultimate goal when selecting a framework, is to find one that allows you to work in a way that is natural to you, provides you the services that are most common to your application and allows you to concentrate on building the code business logic of your application.


To be fair though, the right framework for you is the one that lets you be productive quickest and leverage your new skills the longest.











Saturday, August 4, 2012

Antivirus For Linux


Does a Linux user need antivirus software? Not really: infecting a Linux machine is pretty hard to do. 
If you are using pen drives into Windows computers, it might be infected by virus. so, using same pen drive on more Windows computers spreads malware with it. So, antivirus tools for Linux are going to check and remove Windows virus from your drive.

Avast Antivirus :
This is powerful antivirus engine. Download Latest stable version from Avast's official home page and register it for one year. It has good GUI also.


Download it and enjoy it....

Saturday, July 28, 2012

PHP : MDULE 0 Framework

It was a 1st time, during designing video sharing site inspired by youtube, I've designed single tier php framework, but didn't got any success. Because, it was easy to hack in less time.


So, during Italian large scale healthcare project "SalusBank", I redesigned that framework again, and use the real power of PHP engine. This new framework has more much capabilities against simple hacking, yet not covered more security features. But by using Apache and your server you can add more security features.

So, any framework developer can be easily contribute to project to make it bigger and beautiful. This framework is in its baby stage at Alpha 0.0 version. And It'll be publicly available at last week of August.

You're welcome to give me suggestions any time.
Official Site

Friday, June 15, 2012

PHP Uploader in Fedora server

When Linux comes in mind, we always imagine about its powerful security and privileges for all files and directories. we have to change right being as administrator.
If you have configured as per any tutorials , then it'll perfectly work for your web development. But some things are still remaining.
In most of projects, we want at-least some small document or photo up-loader. So, by default, if you direct uses code of upload in php, it'll give error.

so, follow these steps for healing this problem.

step 1 : in which directory, item will be uploaded, give permission to "apache" for that directory.
                                chown apache  /destination-directory-path/


now, fire :   ls -la


now, this destination directory will show you like this.


drwxr-xr-x  2  apache  savan  4096  Jun 14 17:34  destination-dir


now, you can use your any php uploader code logic. I'll upload perfectly.


in short, you have give permissions to "apache" and it'll start working well.

If you have any further queries you can comment in post.

Setup Server on Fedora 16

Hello, I've used Fedora 14 for all time and for my project works and developments. I think it was a very stable version of Fedora family. Then I moved to Fedora 16. It's gnome 3 environment was great. I became fan of it. and I installed it in my personal laptop also. But when I was starting server httpd it was not starting properly. and was throwing failure for starting server.

So, in this post I'll include that, how I set up server on my laptop.

step 1 :  Remove httpd server inbuilt with fedora 16.  [if you've installed from your Fedora DVD. ]
                              yum remove httpd


this will remove httpd as well as php from your system.

step 2 : Again install httpd server.
                             yum install httpd
                              yum install php
this will install properly configured apache httpd server.


step 3 :  now start httpd server.
                             service httpd start




Now, it'll work properly and goto your browser.

Sunday, March 11, 2012

My Zip v1.0

This is Java based Compression and decompression utility. This can be used for .zip file formats.
This version 1.0 is very basic utility. Advance GUI interface and with optimizing code version 2.0 is under development.

Download :
Support your own development.

Install PHPMyAdmin in Fedora server

This is about to install phpmyadmin in your Fedora based servers. That can simplify your task to manage database. So, no need to use terminals and fire queries in database.

1.) yum install phpmyadmin
2.) now open terminal and login into mysql database

   now type :
     CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';
     GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;

3.) now open browser -> type : http://localhost/phpmyadmin -> enter user name and password : admin

and enjoy it..!!!

Fedora Server

If you have installed Fedora server and want to configure server, i.e. http and mysql are already installed with your fedora.  then this tutorial is for you.

Step 1 :
 Open your terminal and login as a super user.



Step 2 :
 type:
a.)  service httpd start  [for starting http server].

b.) service mysqld start [for starting mysql server]


Step 3 :

  • to see your http server started or nor ?  : open browser -> type : http://locahost/ then it'll show you default page of server.
  • to see your mysql server :  open new terminal -> type :  mysql -u root

  • to start services from booting operating system:
    • chkconfig --levels 235 httpd on   [for http server]
    • chkconfig --levels 235 mysqld on [for mysql server]

Now, your http and database servers are ready to use.

to put your content in your server, put them all in /var/www/html directory.


Note : To install http and mysql server from ground I'll explain it in next tutorial.