Friday, October 31, 2014

How to install PHPRoad (phpr) framework on php 5.5

Install PHPRoad on php 5.5:

PHPRoad is a framework which is used for developing web applications. But it has some limitations like it supports only php 5.4 and older version.

This Framework is not useful in case of php 5.5 . Because, some mysql extenstions does not support php 5.5 like mysql_connect. php 5.5 only supports mysqli_connect.

So, For installation of phpRoad in php 5.5 we have to follow the following steps

Step 1:

Firstly Download the zip and extract it on your local machine.

Step 2:

Run it on browser and follow the steps (Including creating key from phproad)

Here, you will face a problem during installation and that is about 
mysqli_connect

For removing it follow the Step 3

Step 3:
 Open this file

Your_application/framework/modules/db/classes/mysql_driver.php

(a). Here edit mysql_connect to mysqli_connect

also add $this->config['database'] in its Db::$connection (Because mysqli takes 4 parameters )

(b). Change all the mysql_ to mysqli_ in this file .

After this retry it on browser.

This time it will be installed successfully.

Thanks
Ashish Ginotra

Friday, October 17, 2014

How to get all addresses with in a radius from a fixed point in database?

Get all Lat. & Lng. w.r.t. a Lat. & Lng. in a radius:

If you want to find out all the latitudes and longitudes with in a given radius from a given latitude & longitude in a database then you have to do this task.

DB Structure:

id    lat                  lng
1    37.386337     -122.085823
2    37.393887     -122.078918
3    37.394012     -122.095528
4    37.402653     -122.079353


In PHP we can use this kind of variables:

$lat = 37, $lng= -122, $radius= 28;

Now if we want to use its radius should be in miles then we will use code 3959
Now if we want to use its radius should be in k.m. then we will use code 6371

Then query is :

"SELECT *,lat, lng, ( 3959 * acos( cos( radians( $lat ) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians( $lng ) ) + sin( radians( $lat ) ) * sin( radians( lat ) ) ) ) AS distance FROM table  HAVING distance < $radius ORDER BY distance "

You will get a result all the latitudes and longitude ids which are exists with in 28 miles radius from your given latitude and longitude.

Thanks
 

Friday, October 10, 2014

How to integrate oauth2 in your laravel application

oauth2 in laravel:

For integrate oauth2 in your laravel application, we have to follow these steps.

Firstly install it using composer.

Write this line in your composer.json 
"lucadegasperi/oauth2-server-laravel": "3.0.x"
and the run this command "update composer"

Now , add these lines in your provider array of this file app/config/app.php 

'LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider',
'LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider',

and this line in your aliases array
'Authorizer' => 'LucaDegasperi\OAuth2Server\Facades\AuthorizerFacade',

That's it, It is now integrated.

Thanks