-
-
Notifications
You must be signed in to change notification settings - Fork 442
Plugin Development Guide
Jaeger edited this page Oct 10, 2017
·
2 revisions
Your plugin needs to implement QL\Contracts\PluginContract
interface.
QL\Contracts\PluginContract
:
interface PluginContract
{
public static function install(QL\QueryList $queryList,...$opt);
}
composer require jaeger/querylist --dev
use QL\Contracts\PluginContract;
use QL\QueryList;
class MyPlugin implements PluginContract
{
public static function install(QueryList $queryList, ...$opt)
{
// TODO: Implement install() method.
}
}
class MyPlugin implements PluginContract
{
//Defines a static install method for installing your extensions
public static function install(QueryList $queryList,...$opt)
{
//In this method to implement your `bind`
$queryList->bind('myHttp',function($url){
// $this is the current QueryList object
return MyPlugin::get($this,$url);
});
}
//Define a http get method
public static function get($queryList,$url)
{
$html = file_get_contents($url);
$queryList->setHtml($html);
return $queryList;
}
}
$ql = QueryList::use(MyPlugin::class);
$ql->myHttp('https://github.com/');
echo $ql->getHtml();
Reading the existing plugin source allows you to get started quickly.
see: https://github.com/jae-jae/QueryList-AbsoluteUrl
see: https://github.com/jae-jae/QueryList-CurlMulti
Submit your plugin to the community so that more people find your plugin.