2lenet/invoice-bundle
Symfony bundle to manage invoices in your project. Configure Doctrine resolve_target_entities to map bundle interfaces (Customer, Product, Invoice, Payment, etc.) to your own entities, then implement provided interfaces/traits. Includes PDF generator settings (logo/header/footer).
composer require 2le/invoice-bundle
config/packages/doctrine.yaml:
orm:
resolve_target_entities:
Lle\InvoiceBundle\Model\CustomerInterface: App\Entity\User
Lle\InvoiceBundle\Model\InvoiceInterface: App\Entity\Invoice
Lle\InvoiceBundle\Model\InvoiceLineInterface: App\Entity\InvoiceLine
Lle\InvoiceBundle\Model\PaymentInterface: App\Entity\Payment
Invoice):
use Lle\InvoiceBundle\Model\InvoiceTrait;
class Invoice implements InvoiceInterface
{
use InvoiceTrait;
// ...
}
Generate a draft invoice for a user:
use Lle\InvoiceBundle\Manager\InvoiceManager;
public function createDraft(InvoiceManager $invoiceManager, User $user): Response
{
$invoice = $invoiceManager->generate($user);
// Persist $invoice if needed
return $this->render('invoice/create.html.twig', ['invoice' => $invoice]);
}
Invoice Creation:
InvoiceManager to generate drafts or validate invoices.CustomerInterface (e.g., User):
$invoice = $invoiceManager->generate($customer);
$invoiceManager->validate($invoice);
PDF Generation:
lle_invoice.yaml:
lle_invoice:
logo: 'public/assets/logo.png'
header: 'Company Name\nAddress'
footer: 'Thank you for your business'
InvoicePDF service (if available in newer versions).Exporting:
$invoiceExporter->export([$invoice1, $invoice2], 'invoices.csv');
# config/packages/easy_admin.yaml
easy_admin:
entities:
Invoice: App\Entity\Invoice
InvoiceLine: App\Entity\InvoiceLine
InvoiceTrait) to add fields/methods:
class Invoice implements InvoiceInterface
{
use InvoiceTrait;
public function getCustomField(): string
{
return $this->customField;
}
}
Doctrine Target Entities:
CustomerInterface) to concrete entities causes runtime errors.resolve_target_entities in doctrine.yaml matches your bundle’s expectations.Trait Conflicts:
InvoiceTrait) may break bundle functionality.use InvoiceTrait { method as private; } to avoid conflicts.PDF Generation:
InvoicePDF service is undocumented in the README but referenced in usage examples.InvoiceExporter or use a third-party library (e.g., dompdf) if PDF generation is critical.validate() fails silently, enable Doctrine debug mode:
# config/packages/dev/doctrine.yaml
doctrine:
dbal:
logging: true
number, date) are set before validation. Use InvoiceTrait methods like setNumber() if needed.InvoiceExporter to support additional formats (e.g., Excel):
class CustomExporter extends InvoiceExporter
{
public function exportToExcel(array $invoices, string $filename): void
{
// Logic here
}
}
PaymentInterface and integrate with payment gateways (e.g., Stripe) via PaymentManager.config/packages/lle_invoice.yaml:
lle_invoice:
translations:
invoice: 'Facture' # French for "Invoice"
How can I help you explore Laravel packages today?