1. Go to this page and download the library: Download phpsoftbox/inertia 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/ */
use PhpSoftBox\Inertia\View\PhpViewRenderer;
$renderer = PhpViewRenderer::fromConfig($inertiaConfig, ['vite' => $vite]);
use PhpSoftBox\Inertia\View\InertiaHtml;
use PhpSoftBox\Inertia\Integration\ResourcePayloadNormalizer;
$normalizer = new ResourcePayloadNormalizer($resourceSerializer);
$inertia = new Inertia(
// ...
payloadNormalizer: $normalizer,
);
use PhpSoftBox\Inertia\Page\PageMeta;
$meta->setTitle('Панель управления')
->setDescription('Админ‑панель проекта')
->setKeywords(['admin', 'dashboard']);
return $inertia->render('Dashboard');
use PhpSoftBox\Inertia\Page\Menu;
use PhpSoftBox\Inertia\Page\MenuItem;
use PhpSoftBox\Inertia\Page\MenuMatchMode;
$menu = new Menu();
$menu->add(
(new MenuItem('Dashboard', '/', 'dashboard', 'dashboard'))
->withMatchMode(MenuMatchMode::EQUALS),
);
$menu->add(
(new MenuItem('Промо', null, 'promo', 'promo'))
->setChildren([
new MenuItem('Промокоды', '/promo/promocodes', 'promocode', 'promocode'),
]),
);
use PhpSoftBox\Auth\Middleware\AreaAccessDeniedMode;
use PhpSoftBox\Auth\Middleware\AreaAccessRule;
new AreaAccessRule(
area: 'admin',
permission: 'admin.access',
deniedMode: AreaAccessDeniedMode::NotFound,
)
use PhpSoftBox\Inertia\Area\AreaSharedDataProviderInterface;
final class AdminSharedDataProvider implements AreaSharedDataProviderInterface
{
public function area(): string
{
return 'admin';
}
public function share(ServerRequestInterface $request): array
{
return [
'admin' => [
'sidebar' => [],
],
];
}
}