1. Go to this page and download the library: Download wiznetic/corenetic-base 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/ */
wiznetic / corenetic-base example snippets
// Example: a module that runs on every request
Kernel::on('request', function ($ctx) {
// $ctx->request — the incoming request
// $ctx->response — set this to send a response
// $ctx->data — shared data between hooks
});
Kernel::handle(); // fires the full pipeline
// bootstrap.php runs Modules::register() — all module register() methods are called
// Kernel::handle() is NOT called — CLI modules boot themselves in their commands
Application::create()->run();
// app_modules/Cache/app/Bootstrap/Cache.php
class Cache
{
public static function register(): void
{
Kernel::on('request', function () {
$config = Config::get('cache');
Store::boot(new CacheContainer($config));
});
}
}
// Consumer Bootstrap — checks if provider exists before hooking in
if (class_exists(\Cache\Services\Store::class)) {
\Cache\Services\Store::addResolver(
fn(string $key, callable $cb) => Discovery::cache($key, $cb)
);
}
// app_modules/MyModule/app/Bootstrap/MyModule.php
namespace MyModule\Bootstrap;
use Wiznetic\Kernel\Kernel;
use MyModule\Containers\MyContainer;
use MyModule\Services\MyService;
class MyModule
{
public static function register(): void
{
Kernel::on('request', function () {
MyService::boot(new MyContainer());
});
}
}
// app_modules/MyModule/app/Services/MyService.php
namespace MyModule\Services;
class MyService
{
private static ?MyContainer $container = null;
public static function boot(MyContainer $container): void
{
static::$container = $container;
}
public static function doSomething(): string
{
return static::$container->dependency->run();
}
}
use MyModule\Services\MyService;
MyService::doSomething();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.