Skip to content

The HydeKernel

Introduction

In the centre, or should I say core, of HydePHP is the HydeKernel. The kernel encapsulates a HydePHP project and provides helpful methods for interacting with it. You can think of it as the heart of HydePHP, if you're a romantic.

The HydeKernel is so important that you have probably used it already. The main entry point for the HydePHP API is the Hyde facade, which calls methods on the kernel.

use Hyde\Hyde;
use Hyde\Foundation\HydeKernel;

Hyde::version(); // calls $HydeKernel->version()

The kernel is created very early on in the application lifecycle, in the bootstrap.php file, where it is also bound as a singleton into the application service container.

Accessing the Kernel

The HydeKernel is stored as a singleton in a static property in its own class and can be accessed in a few ways.

Commonly, you'll use the Hyde facade which forwards calls to the singleton instance. You can also use the hyde() function to get the Kernel, and call methods on it.

Since the instance is also bound into the Laravel Application Service Container you can also use Dependency Injection by type-hinting the HydeKernel::class.

Here are some examples of how you can call methods on the Kernel. All methods call the same method on the same instance, so it's just a matter of preference.

use Hyde\Hyde;
use Hyde\Foundation\HydeKernel;

Hyde::version();
Hyde::kernel()->version();
HydeKernel::getInstance()->version();
app(HydeKernel::class)->version();
hyde()->version();

The Kernel instance is constructed in bootstrap.php, and is available globally as $hyde.

The Kernel Lifecycle

Whenever we talk about the kernel being "booted" we are talking about the kernel's role in the autodiscovery process.

You can read all about it in the Autodiscovery Documentation.

API Reference

Since the most common way to interact with the kernel is through the Hyde facade, we will use that for the examples. But you could just as well chain the methods on the accessed kernel singleton instance if you wanted.

version()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::version(): string

__construct()

No description provided.

// torchlight! {"lineNumbers": false}
$hyde = new HydeKernel(string $basePath): void

features()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::features(): Hyde\Facades\Features

hasFeature()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::hasFeature(string $feature): bool

toArray()

Get the instance as an array.

// torchlight! {"lineNumbers": false}
Hyde::toArray(): array<TKey, TValue>

files()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::files(): \Hyde\Foundation\Kernel\FileCollection<string, \Hyde\Support\Filesystem\ProjectFile>

pages()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::pages(): \Hyde\Foundation\Kernel\PageCollection<string, \Hyde\Pages\Concerns\HydePage>

routes()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::routes(): \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\Route>

makeTitle()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::makeTitle(string $value): string

normalizeNewlines()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::normalizeNewlines(string $string): string

stripNewlines()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::stripNewlines(string $string): string

trimSlashes()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::trimSlashes(string $string): string

markdown()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::markdown(string $text, bool $normalizeIndentation): Illuminate\Support\HtmlString

filesystem()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::filesystem(): Hyde\Foundation\Kernel\Filesystem

path()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::path(string $path): string

vendorPath()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::vendorPath(string $path, string $package): string

mediaPath()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::mediaPath(string $path): string

sitePath()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::sitePath(string $path): string

siteMediaPath()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::siteMediaPath(string $path): string

pathToAbsolute()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::pathToAbsolute(array|string $path): array|string

pathToRelative()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::pathToRelative(string $path): string

getInstance()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getInstance(): Hyde\Foundation\HydeKernel

setInstance()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::setInstance(Hyde\Foundation\HydeKernel $instance): void

getBasePath()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getBasePath(): string

setBasePath()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::setBasePath(string $basePath): void

getSourceRoot()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getSourceRoot(): string

setSourceRoot()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::setSourceRoot(string $sourceRoot): void

getOutputDirectory()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getOutputDirectory(): string

setOutputDirectory()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::setOutputDirectory(string $outputDirectory): void

getMediaDirectory()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getMediaDirectory(): string

setMediaDirectory()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::setMediaDirectory(string $mediaDirectory): void

getMediaOutputDirectory()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getMediaOutputDirectory(): string

registerExtension()

Register a HydePHP extension within the HydeKernel.

Typically, you would call this method in the register method of a service provider. If your package uses the standard Laravel (Composer) package discovery feature, the extension will automatically be enabled when the package is installed.

// torchlight! {"lineNumbers": false}
Hyde::registerExtension(class-string&lt;\Hyde\Foundation\Concerns\HydeExtension&gt; $extension): void

getExtension()

Get the singleton instance of the specified extension.

// torchlight! {"lineNumbers": false}
Hyde::getExtension(class-string&lt;T&gt; $extension): T

hasExtension()

Determine if the specified extension is registered.

// torchlight! {"lineNumbers": false}
Hyde::hasExtension(class-string&lt;\Hyde\Foundation\Concerns\HydeExtension&gt; $extension): bool

getExtensions()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getExtensions(): array<\Hyde\Foundation\Concerns\HydeExtension>

getRegisteredExtensions()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getRegisteredExtensions(): array<class-string<\Hyde\Foundation\Concerns\HydeExtension>>

getRegisteredPageClasses()

No description provided.

// torchlight! {"lineNumbers": false}
Hyde::getRegisteredPageClasses(): array<class-string<\Hyde\Pages\Concerns\HydePage>>

shareViewData()

Share data for the page being rendered.

// torchlight! {"lineNumbers": false}
Hyde::shareViewData(Hyde\Pages\Concerns\HydePage $page): void

currentRouteKey()

Get the route key for the page being rendered.

// torchlight! {"lineNumbers": false}
Hyde::currentRouteKey(): string

currentRoute()

Get the route for the page being rendered.

// torchlight! {"lineNumbers": false}
Hyde::currentRoute(): Hyde\Support\Models\Route

currentPage()

Get the page being rendered.

// torchlight! {"lineNumbers": false}
Hyde::currentPage(): Hyde\Pages\Concerns\HydePage

isBooted()

Determine if the Kernel has booted.

// torchlight! {"lineNumbers": false}
Hyde::isBooted(): bool

boot()

Boot the Hyde Kernel and run the Auto-Discovery Process.

// torchlight! {"lineNumbers": false}
Hyde::boot(): void

booting()

Register a new boot listener.

Your callback will be called before the kernel is booted. You can use this to register your own routes, pages, etc. The kernel instance will be passed to your callback.

// torchlight! {"lineNumbers": false}
/** @param callable(\Hyde\Foundation\HydeKernel): void $callback */
Hyde::booting(callable(\Hyde\Foundation\HydeKernel): void): void

booted()

Register a new "booted" listener.

Your callback will be called after the kernel is booted. You can use this to run any logic after discovery has completed. The kernel instance will be passed to your callback.

// torchlight! {"lineNumbers": false}
/** @param callable(\Hyde\Foundation\HydeKernel): void $callback */
Hyde::booted(callable(\Hyde\Foundation\HydeKernel): void): void