1. Go to this page and download the library: Download rokke/contracts 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/ */
rokke / contracts example snippets
use Rokke\Contracts\Module\ModuleInterface;
final class HttpModule implements ModuleInterface
{
public function name(): string { return 'http'; }
public function boot(): void { /* register services */ }
public function start(): void { /* start server */ }
public function stop(): void { /* graceful shutdown */ }
public function health(): bool { return true; }
public function dependencies(): array { return []; }
}
use Rokke\Contracts\Lifecycle\LifecycleEventsInterface;
$lifecycle->onRunning(function (): void {
// application is fully started
});
$lifecycle->onStopping(function (): void {
// drain in-flight requests
});