1. Go to this page and download the library: Download kleinweb/lib 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/ */
kleinweb / lib example snippets
use Kleinweb\Lib\Hooks\Attributes\Action;
use Kleinweb\Lib\Hooks\Attributes\Filter;
use Kleinweb\Lib\Support\ServiceProvider;
class MyServiceProvider extends ServiceProvider
{
#[Action('init')]
public function onInit(): void
{
// Runs on WordPress 'init' action
}
#[Filter('the_content', priority: 20)]
public function filterContent(string $content): string
{
return $content . '<p>Appended content</p>';
}
}
use Kleinweb\Lib\Package\Package;
use Kleinweb\Lib\Package\PackageServiceProvider;
class MyPackageServiceProvider extends PackageServiceProvider
{
public function configurePackage(Package $package): void
{
$package
->name('my-package')
->hasConfigFile()
->hasViews()
->hasMigrations('create_items_table')
->hasCommands(MyCommand::class);
}
}
use Kleinweb\Lib\Tenancy\Site;
Site::name(); // Current site name
Site::url(); // Site URL as League\Uri instance
Site::host(); // Current hostname
Site::isPrimaryHost(); // Check if on main site
Site::originalHost(); // Get original domain from site meta
use Kleinweb\Lib\Log\SimpleHistoryHandler;
use Monolog\Logger;
$logger = new Logger('my-channel');
$logger->pushHandler(new SimpleHistoryHandler());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.