laylatichy\nano\Nano
useNano()
is a helper function to get the nano instance
useNano(): Nano
useNano
(): Nano
php
useNano();
start(): void
start
(): void
start the nano server
php
useNano()->start();
withOptions(array $options): Nano
withOptions
(array $options
): Nano
pass context options to the nano server
https://www.php.net/manual/en/function.stream-context-create.php
php
useNano()->withOptions([
'ssl' => [
'local_cert' => '/path/to/cert.pem',
'local_pk' => '/path/to/private.key',
],
]);
getCache(): Cache
getCache
(): Cache
get the cache instance
php
useNano()->getCache(); // same as useCache()
withCache(CacheStatus $option, int $mins): Nano
withCache
(CacheStatus $option,
int $mins
): Nano
set cache status and cache time
php
useNano()->withCache(CacheStatus::ENABLED, 60);
withoutCache(): Nano
withoutCache
(): Nano
disable cache
php
useNano()->withoutCache();
getHeaders(): Headers
getHeaders
(): Headers
get the headers instance
php
useNano()->getHeaders(); // same as useHeaders()
withHeader(string $header, string $value): Nano
withHeader
(string $header,
string $value
): Nano
set a global header
php
useNano()->withHeader('Content-Type', 'application/json');
getModules(): <NanoModule::class, NanoModule>[]
getModules
(): <NanoModule::class, NanoModule>[]
get all modules
php
useNano()->getModules();
getModule(string $name): NanoModule
getModule
(string $name
): NanoModule
get a module by class name
php
useNano()->getModule(NanoModule::class);
// or
useNanoModule(NanoModule::class);
withModule(NanoModule $module): Nano
withModule
(NanoModule $module
): Nano
add a module
php
useNano()->withModule(new NanoModule());
getRouter(): Router
getRouter
(): Router
get the router instance
php
useNano()->getRouter(); // same as useRouter()
processes(int $count): Nano
processes
(int $count
): Nano
set the number of processes to run
php
useNano()->processes(4);
destroy(): void
destroy
(): void
destroy the nano instance
php
useNano()->destroy();