Phalcon ULogin. The authorization form uLogin through social networks
- PSR-0, PSR-1, PSR-2, PSR-4 Standards
- PHP 5.4.x >
- Phalcon extension 1.3.x
- \Phalcon\Session in DI
First update your dependencies through composer. Add to your composer.json:
"require": {
"stanislav-web/phalcon-ulogin": "1.0-stable"
}
php composer.phar install
OR
php composer.phar require stanislav-web/phalcon-ulogin dev-master
(Do not forget to include the composer autoloader)
Or manual require in your loader service
$loader->registerNamespaces([
'ULogin\Auth' => 'path to src'
]);
You can create an injectable service
$this->di['ulogin'] = function() {
return new ULogin\Auth();
};
use ULogin\Auth;
echo (new Auth())->getForm();
echo (new Auth())->setType('window')->getForm(); // window, panel, small as default
echo (new Auth())->setProviders([
'vkontakte' => true, // show inline
'odnoklassniki' => true, // show inline
'facebook' => false, // show in drop down
'google' => false, // show in drop down
'yandex' => true, // show inline
])->setType('panel')->getForm();
echo (new Auth())->setProviders('vkontakte=true,odnoklassniki=true,facebook=false,google=false,yandex=true')->setType('panel')->getForm();
echo (new Auth())->setType('panel')->setUrl('?success')->getForm();
echo (new Auth())->setFields([
'first_name',
'last_name',
'photo',
'city'
])->getForm();
echo (new Auth())->setFields('first_name,last_name,photo,city')->getForm();
$ulogin = new Auth(array(
'fields' => 'first_name,last_name,photo,city',
'providers' => 'vk=true,mailru=false,linkedin=false',
'url' => '/auth/?success',
'type' => 'window'
));
echo $ulogin->getForm();
$ulogin = new Auth();
// print form
echo $ulogin->setUrl('?success')->getForm();
// handler
$request = new \Phalcon\Http\Request();
if($request->hasQuery('success') === true) {
// check authorization
if($ulogin->isAuthorised()) {
// get auth token
echo $ulogin->getToken();
// get auth user data
var_dump($ulogin->getUser());
// logout
$ulogin->logout();
}
}
Also available in /phpunit directory. Run command to start
php build/phpunit.phar --configuration phpunit.xml.dist --coverage-text
Read logs from phpunit/log
##Issues