1. Go to this page and download the library: Download neophp-package/neo-admin 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/ */
neophp-package / neo-admin example snippets
namespace App\Admin\Badge;
use App\Entity\Report;
use NeoPHP\NeoAdmin\Menu\Contract\BadgeInterface;
use NeoPHP\Package\Orm\OrmManagerInterface;
class PendingReportsBadge implements BadgeInterface
{
public function __construct(protected OrmManagerInterface $orm)
{
}
public function getValue(): int|string|null
{
return $this->orm->getRepository(Report::class)->count(['status' => 'pending']);
}
}
namespace App\Admin\Translation;
use App\Repository\LanguageRepository;
use NeoPHP\NeoAdmin\Contract\LocaleProviderInterface;
class LanguageLocaleProvider implements LocaleProviderInterface
{
public function __construct(protected LanguageRepository $languages)
{
}
public function getLocales(): array
{
$locales = [];
foreach ($this->languages->findBy([], ['position' => 'ASC']) as $language) {
$locales[$language->getCode()] = $language->getName();
}
return $locales;
}
}
namespace App\Controller\Admin;
use App\Service\Analytics;
use NeoPHP\Component\Http\Request\Request;
use NeoPHP\Component\Http\Response\Response;
use NeoPHP\Component\Routing\Attribute\Route;
use NeoPHP\NeoAdmin\Contract\AbstractAdminController;
use NeoPHP\NeoAdmin\Page\Action;
use NeoPHP\NeoAdmin\Page\Block\Grid;
use NeoPHP\NeoAdmin\Page\Column;
class AnalyticsController extends AbstractAdminController
{
#[Route('/admin/analytics', name: 'admin_analytics', methods: ['GET'])]
public function index(Request $request, Analytics $analytics): Response
{
$this->denyUnlessAdmin();
$days = in_array($days = $request->query->getInt('days', 7), [7, 30, 90], true) ? $days : 7;
$summary = $analytics->summary($days);
return $this->page('Analytics')
->description(sprintf('Page views of the last %d days.', $days))
->action(Action::link('Open the site', '/', 'external')->blank())
->tabs('days', [7 => '7 days', 30 => '30 days', 90 => '90 days'], $days)
->grid(3, fn (Grid $grid) => $grid
->stat('Page views', $summary['views'], 'eye', trend: 8.2)
->stat('Unique visitors', $summary['visitors'], 'users')
->stat('Average response', $summary['avg_ms'] . ' ms', 'chart'))
->chart('Views per day', $analytics->perDay($days), ['views' => 'Views', 'visitors' => 'Visitors'])
->grid(2, fn (Grid $grid) => $grid
->table('Top pages', $analytics->topPaths($days), [
'path' => Column::code('path', 'Page')->url(fn (array $row) => $row['path']),
'views' => 'Views',
], icon: 'file', empty: 'No page view yet.')
->table('Not found (404)', $analytics->notFound($days), ['path' => 'Page', 'views' => 'Views'], icon: 'search'))
->render();
}
}
namespace App\Admin\Widget;
use App\Service\Analytics;
use NeoPHP\NeoAdmin\Page\Block\Stat;
use NeoPHP\NeoAdmin\Page\Contract\BlockInterface;
use NeoPHP\NeoAdmin\Page\Contract\WidgetInterface;
class TrafficWidget implements WidgetInterface
{
public function __construct(protected Analytics $analytics)
{
}
public function build(): BlockInterface
{
return new Stat('Views today', $this->analytics->summary(1)['views'], 'eye');
}
}
bash
php bin/neo make:admin:entity BlogPost
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.