1. Go to this page and download the library: Download nubitio/admin-bundle 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/ */
nubitio / admin-bundle example snippets
use ApiPlatform\Metadata\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Nubit\ApiPlatform\Doctrine\Money\MoneyColumns;
use Nubit\Platform\Money\Money;
use Symfony\Component\Serializer\Attribute\Ignore;
#[ApiResource]
class Invoice
{
// Name the embedded property something other than the exposed field, mark
// it #[Ignore], and set columnPrefix — see MoneyColumns for why.
#[ORM\Embedded(class: MoneyColumns::class, columnPrefix: 'total_')]
#[Ignore]
private MoneyColumns $totalColumns;
public function getTotal(): ?Money
{
return $this->totalColumns->toMoney();
}
public function setTotal(?Money $total): void
{
$this->totalColumns = MoneyColumns::fromMoney($total);
}
}
$unit = Money::of('19.99', 'EUR');
$line = $unit->multipliedBy(3); // exact, no rounding needed
$tax = $line->multipliedBy('0.21', RoundingMode::HalfUp);
$total = $line->plus($tax);
// Splitting without losing a cent:
[$a, $b, $c] = $total->allocate([1, 1, 1]); // always sums back to $total
#[ApiResource]
#[Printable(template: InvoiceTemplate::class, numberProperty: 'number')]
class Invoice { … }
final class InvoiceTemplate implements DocumentTemplateInterface
{
public function render(object $resource, DocumentRenderContext $context): string
{
// Return HTML. The context carries the document number, the issue
// instant and the display timezone, so the same template renders
// identically from a request, a worker and a test.
}
}
// src/Runtime/AppRuntimeConfigProvider.php
final readonly class AppRuntimeConfigProvider implements RuntimeConfigProviderInterface
{
public function getConfig(): array
{
return [
'ui' => ['showBranchPicker' => false],
'defaults' => ['currency' => 'USD'],
];
}
}
#[Auditable] // or #[Auditable(resource: 'products')]
#[ORM\Entity]
class Product { ... }
use Nubit\ApiPlatform\Attribute\Exportable;
#[ApiResource]
#[ApiFilter(DataGridFilter::class)]
#[Exportable]
class Product { /* … */ }
#[Exportable(operations: ['_api_/products{._format}_get_collection'])] // collection only
use Nubit\Platform\Notification\Contract\NotificationDispatcherInterface;
use Nubit\Platform\Notification\NotificationMessage;
$dispatcher->dispatch(new NotificationMessage(
recipient: $user->getUserIdentifier(), // a plain identifier string, not a User FK
subject: 'Invoice INV-0042 confirmed',
body: 'The invoice was confirmed and is awaiting payment.',
channels: ['email', 'in_app'], // [] means every registered channel
context: ['html' => $renderedHtml], // channel-specific extras
));