1. Go to this page and download the library: Download dual-native/http-system 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/ */
use DualNative\HTTP\DualNativeSystem;
use DualNative\HTTP\Events\WordPressEventDispatcher;
use DualNative\HTTP\Storage\WordPressStorage;
// Initialize with WordPress adapters
$system = new DualNativeSystem(
[
'version' => '1.0.0',
'profile' => 'full',
'cache_ttl' => 3600
],
new WordPressEventDispatcher(), // Bridges to do_action/apply_filters
new WordPressStorage() // Bridges to get_option/update_option
);
// Now WordPress hooks work through the library
add_action('dual_native_system_initialized', function($system) {
// System is ready
});
use DualNative\HTTP\DualNativeSystem;
use DualNative\HTTP\Events\EventDispatcherInterface;
use DualNative\HTTP\Storage\StorageInterface;
// Create Laravel adapters
class LaravelEventDispatcher implements EventDispatcherInterface {
public function dispatch(string $eventName, ...$args): void {
event($eventName, $args);
}
public function filter(string $filterName, $value, ...$args) {
return $value; // Or implement Laravel's equivalent
}
public function hasListeners(string $eventName): bool {
return Event::hasListeners($eventName);
}
}
class LaravelStorage implements StorageInterface {
public function get(string $key, $default = null) {
return cache()->get($key, $default);
}
public function set(string $key, $value): bool {
return cache()->put($key, $value, 3600);
}
public function delete(string $key): bool {
return cache()->forget($key);
}
public function has(string $key): bool {
return cache()->has($key);
}
}
// Initialize system
$system = new DualNativeSystem(
config('dualnative'),
new LaravelEventDispatcher(),
new LaravelStorage()
);
// Get current resource
$resource = $system->getResource('post-123');
$currentCid = $resource['cid'];
// Update with CID validation
$result = $system->updateResource(
'post-123',
$newData,
$currentCid // Must match current state
);
if ($result['success']) {
$newCid = $result['new_cid'];
} else {
// 412 Precondition Failed - resource was modified by another process
$actualCid = $result['actual_cid'];
}
// Create a resource
$result = $system->createResource(
'post-123', // Resource ID
['url' => 'https://example.com/post'], // Human Representation
['api_url' => 'https://api.example.com/post/123', 'title' => '...'], // Machine Representation
['author' => 'John Doe'] // Metadata
);
// Get catalog
$catalog = $system->getCatalog(
$since = '2024-01-01T00:00:00Z', // Only resources updated since
$filters = ['status' => 'publish'],
$limit = 100,
$offset = 0
);