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.
1use Hyde\Hyde;2use Hyde\Foundation\HydeKernel;3 4Hyde::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 It is stored as a singleton in this class, and is bound into the Laravel Application Service Container, and can be accessed in a few ways.
Commonly, you'll use the Hyde facade, but you can also use Dependency Injection
by type-hinting the HydeKernel::class, or use the hyde() function to get the Kernel.
The Kernel instance is constructed in bootstrap.php, and is available globally as $hyde.
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.
1use Hyde\Hyde;2use Hyde\Foundation\HydeKernel;3 4Hyde::version();5Hyde::kernel()->version();6HydeKernel::getInstance()->version();7app(HydeKernel::class)->version();8hyde()->version();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.
Hyde::version(): string__construct()#
No description provided.
$hyde = new HydeKernel(string $basePath): voidfeatures()#
No description provided.
Hyde::features(): Hyde\Facades\FeatureshasFeature()#
No description provided.
Hyde::hasFeature(string $feature): booltoArray()#
Get the instance as an array.
Hyde::toArray(): array<TKey, TValue>files()#
No description provided.
Hyde::files(): \Hyde\Foundation\Kernel\FileCollection<string, \Hyde\Support\Filesystem\ProjectFile>pages()#
No description provided.
Hyde::pages(): \Hyde\Foundation\Kernel\PageCollection<string, \Hyde\Pages\Concerns\HydePage>routes()#
No description provided.
Hyde::routes(): \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\Route>makeTitle()#
No description provided.
Hyde::makeTitle(string $value): stringnormalizeNewlines()#
No description provided.
Hyde::normalizeNewlines(string $string): stringstripNewlines()#
No description provided.
Hyde::stripNewlines(string $string): stringtrimSlashes()#
No description provided.
Hyde::trimSlashes(string $string): stringmarkdown()#
No description provided.
Hyde::markdown(string $text, bool $normalizeIndentation): Illuminate\Support\HtmlStringformatLink()#
No description provided.
Hyde::formatLink(string $destination): stringrelativeLink()#
No description provided.
Hyde::relativeLink(string $destination): stringmediaLink()#
No description provided.
Hyde::mediaLink(string $destination, bool $validate): stringasset()#
No description provided.
Hyde::asset(string $name, bool $preferQualifiedUrl): stringurl()#
No description provided.
Hyde::url(string $path): stringhasSiteUrl()#
No description provided.
Hyde::hasSiteUrl(): boolfilesystem()#
No description provided.
Hyde::filesystem(): Hyde\Foundation\Kernel\Filesystempath()#
No description provided.
Hyde::path(string $path): stringvendorPath()#
No description provided.
Hyde::vendorPath(string $path, string $package): stringmediaPath()#
No description provided.
Hyde::mediaPath(string $path): stringsitePath()#
No description provided.
Hyde::sitePath(string $path): stringsiteMediaPath()#
No description provided.
Hyde::siteMediaPath(string $path): stringpathToAbsolute()#
No description provided.
Hyde::pathToAbsolute(array|string $path): array|stringpathToRelative()#
No description provided.
Hyde::pathToRelative(string $path): stringgetInstance()#
No description provided.
Hyde::getInstance(): Hyde\Foundation\HydeKernelsetInstance()#
No description provided.
Hyde::setInstance(Hyde\Foundation\HydeKernel $instance): voidgetBasePath()#
No description provided.
Hyde::getBasePath(): stringsetBasePath()#
No description provided.
Hyde::setBasePath(string $basePath): voidgetSourceRoot()#
No description provided.
Hyde::getSourceRoot(): stringsetSourceRoot()#
No description provided.
Hyde::setSourceRoot(string $sourceRoot): voidgetOutputDirectory()#
No description provided.
Hyde::getOutputDirectory(): stringsetOutputDirectory()#
No description provided.
Hyde::setOutputDirectory(string $outputDirectory): voidgetMediaDirectory()#
No description provided.
Hyde::getMediaDirectory(): stringsetMediaDirectory()#
No description provided.
Hyde::setMediaDirectory(string $mediaDirectory): voidgetMediaOutputDirectory()#
No description provided.
Hyde::getMediaOutputDirectory(): stringregisterExtension()#
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.
Hyde::registerExtension(class-string<\Hyde\Foundation\Concerns\HydeExtension> $extension): voidgetExtension()#
Get the singleton instance of the specified extension.
Hyde::getExtension(class-string<T> $extension): ThasExtension()#
Determine if the specified extension is registered.
Hyde::hasExtension(class-string<\Hyde\Foundation\Concerns\HydeExtension> $extension): boolgetExtensions()#
No description provided.
Hyde::getExtensions(): array<\Hyde\Foundation\Concerns\HydeExtension>getRegisteredExtensions()#
No description provided.
Hyde::getRegisteredExtensions(): array<class-string<\Hyde\Foundation\Concerns\HydeExtension>>getRegisteredPageClasses()#
No description provided.
Hyde::getRegisteredPageClasses(): array<class-string<\Hyde\Pages\Concerns\HydePage>>shareViewData()#
Share data for the page being rendered.
Hyde::shareViewData(Hyde\Pages\Concerns\HydePage $page): voidcurrentRouteKey()#
Get the route key for the page being rendered.
Hyde::currentRouteKey(): stringcurrentRoute()#
Get the route for the page being rendered.
Hyde::currentRoute(): Hyde\Support\Models\RoutecurrentPage()#
Get the page being rendered.
Hyde::currentPage(): Hyde\Pages\Concerns\HydePageisBooted()#
Determine if the Kernel has booted.
Hyde::isBooted(): boolboot()#
Boot the Hyde Kernel and run the Auto-Discovery Process.
Hyde::boot(): voidbooting()#
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.
/** @param callable(\Hyde\Foundation\HydeKernel): void $callback */Hyde::booting(callable(\Hyde\Foundation\HydeKernel): void): voidbooted()#
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.
/** @param callable(\Hyde\Foundation\HydeKernel): void $callback */Hyde::booted(callable(\Hyde\Foundation\HydeKernel): void): void