Home

Awesome

QueryList V4 Plugin - SimpleForm

make form submission easier

Installation

composer require liesauer/ql-plugin-simpleform

Bind

Usage

use liesauer\QLPlugin\SimpleForm;
use QL\QueryList;

require_once __DIR__ . '/vendor/autoload.php';

// cookie needed for this example
$cookie = new \GuzzleHttp\Cookie\CookieJar();

$ql = QueryList::getInstance();

// use this plugin
$ql->use(SimpleForm::class);

$username = $ql->simpleForm('https://github.com/login', '', [
    'options' => [
        'verify'  => false,
        'cookies' => $cookie,
    ],
], [
    'params'  => [
        'login'    => 'username',
        'password' => 'password',
    ],
    'options' => [
        'verify'  => false,
        'cookies' => $cookie,
    ],
])->find('.header-nav-current-user>.css-truncate-target')->text();

if (!empty($username)) {
    echo "welcome back, {$username}!\n";
} else {
    $error = $ql->find('.flash-error>.container')->text();
    echo "{$error}\n";
}