Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Testbundle Laravel Package

egorzz/testbundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation

    symfony new project 3.4
    cd project
    composer require egorzz/testbundle dev-master
    
    • Verify vendor/egorzz/testbundle exists (note: namespace mismatch bug documented in README).
  2. Register Bundle Update app/AppKernel.php:

    new Egor\TestBundle\EgorTestBundle(), // Fix namespace after dev resolves
    new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
    new EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle(),
    
  3. First Use Case

    • Check src/Egor/TestBundle/Resources/config/routing.yml for demo routes (e.g., /expense).
    • Run:
      php bin/console cache:clear
      php bin/console doctrine:schema:update --force
      
    • Access http://localhost:8000/app_dev.php/expense to test the expense-tracking demo.

Implementation Patterns

Core Workflows

  1. Expense Tracking Integration

    • Controller Hooks: Extend EgorTestBundle:Expense controller logic in your app’s src/AppBundle/Controller/ExpenseController.php:
      use Egor\TestBundle\Controller\ExpenseController as BaseExpenseController;
      class ExpenseController extends BaseExpenseController {
          public function customAction() { ... }
      }
      
    • Override Templates: Copy vendor/egorzz/testbundle/Resources/views/Expense/index.html.twig to app/Resources/EgorTestBundle/views/Expense/ to customize.
  2. EasyAdmin Integration

    • Use the pre-configured EasyAdminBundle CRUD for Expense entity:
      # app/config/easy_admin.yaml
      easy_admin:
          entities:
              Egor\TestBundle\Entity\Expense:
                  class: Egor\TestBundle\Entity\Expense
                  list: [id, date, amount, category]
      
  3. Paginator Usage

    • Reuse the bundle’s paginator setup in your controllers:
      use Knp\Component\Pager\PaginatorInterface;
      $paginator = $this->get('knp_paginator');
      $expenses = $paginator->paginate(
          $this->getDoctrine()->getRepository('EgorTestBundle:Expense')->findAll(),
          $this->get('request')->query->getInt('page', 1),
          10
      );
      

Laravel Equivalents (Conceptual)

Symfony Pattern Laravel Equivalent Example
Bundle Resources/config config/ files Move routing.ymlconfig/expenses.php as a service provider.
Twig templates Blade views Copy index.html.twigresources/views/expenses/index.blade.php.
Doctrine ORM Eloquent Replace Expense entity with app/Expense.php model.
Kernel events Service Provider boot() Register listeners in AppServiceProvider.

Gotchas and Tips

Pitfalls

  1. Namespace Mismatch

    • Issue: Bundle installs as egorzz/testbundle but defines namespace Egor\TestBundle.
    • Fix: Either:
      • Wait for dev to rename the package, or
      • Manually update composer.json to alias the namespace:
        "autoload": {
            "psr-4": {
                "Egor\\TestBundle\\": "vendor/egorzz/testbundle/src/"
            }
        }
        
      • Run composer dump-autoload.
  2. Symfony 3.4 Deprecations

    • Issue: Uses AppKernel (deprecated in Symfony 4+). Laravel devs may hit:
      • registerBundles() → Use config/bundles.php in Symfony 4.
      • app/Resources/ → Move to config/ or public/ as needed.
    • Fix: Adapt paths or fork the bundle for Symfony 5+.
  3. Doctrine Schema Updates

    • Issue: Running --force may overwrite migrations. Always:
      php bin/console doctrine:migrations:diff
      php bin/console doctrine:migrations:migrate
      

Debugging Tips

  1. Route Debugging

    • Dump routes:
      php bin/console debug:router | grep expense
      
    • Laravel equivalent: php artisan route:list.
  2. Twig Debugging

    • Enable Twig debug mode in app/config/config_dev.yml:
      twig:
          debug: true
          strict_variables: true
      
    • Laravel: Use {{ dump() }} in Blade or dd() in controllers.
  3. Dependency Conflicts

    • If EasyAdminBundle or KnpPaginatorBundle fail:
      composer why-not egorzz/testbundle
      composer require symfony/*:3.4.* --dev
      

Extension Points

  1. Custom Entities

    • Extend the Expense entity by creating a child class:
      namespace AppBundle\Entity;
      use Egor\TestBundle\Entity\Expense as BaseExpense;
      
      class Expense extends BaseExpense {
          // Add custom fields/methods
      }
      
    • Update orm.xml or annotations to map new fields.
  2. Event Listeners

    • Subscribe to bundle events (e.g., expense.pre_save):
      // src/AppBundle/EventListener/ExpenseListener.php
      use Egor\TestBundle\Event\ExpenseEvents;
      use Symfony\Component\EventDispatcher\EventSubscriberInterface;
      
      class ExpenseListener implements EventSubscriberInterface {
          public static function getSubscribedEvents() {
              return [ExpenseEvents::PRE_SAVE => 'onPreSave'];
          }
          public function onPreSave(ExpenseEvent $event) { ... }
      }
      
    • Register in services.yml:
      services:
          app.expense_listener:
              class: AppBundle\EventListener\ExpenseListener
              tags:
                  - { name: kernel.event_subscriber }
      
  3. API Endpoints

    • Expose Expense as an API by creating a custom controller:
      use FOS\RestBundle\Controller\FOSRestController;
      use Egor\TestBundle\Entity\Expense;
      
      class ApiExpenseController extends FOSRestController {
          public function getExpensesAction() {
              return $this->handleView($this->view($this->getDoctrine()
                  ->getRepository('EgorTestBundle:Expense')->findAll()));
          }
      }
      
    • Route in routing.yml:
      api_expenses:
          path: /api/expenses
          defaults: { _controller: AppBundle:ApiExpense:getExpenses }
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views