PHP code example of stanislav-web / phalcon-ulogin

1. Go to this page and download the library: Download stanislav-web/phalcon-ulogin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stanislav-web / phalcon-ulogin example snippets


    $loader->registerNamespaces([
        'ULogin\Auth' => 'path to src'
    ]);

    $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();
        }
    }

php build/phpunit.phar --configuration phpunit.xml.dist --coverage-text
python
php composer.phar install