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

As400 Bundle Laravel Package

cisse/as400-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require cisse/as400-bundle
    

    Register in config/bundles.php:

    Cisse\Bundle\As400\As400Bundle::class => ['all' => true],
    
  2. Configure Connection (config/packages/as400.yaml):

    as400:
        connection:
            driver: "IBM i Access ODBC Driver"
            system: "your-as400-system"
            user: "your-username"
            password: "your-password"
    
  3. First Use Case:

    • Generate an entity from an AS400 table:
      php bin/console as400:generate:entity --table=YOUR_TABLE_NAME --entity=YourEntity
      
    • Use the generated entity in a repository:
      $repository = $this->get('as400.repository.your_entity');
      $entity = $repository->find(1);
      

Implementation Patterns

Entity Definition

Use PHP 8+ attributes to define mappings (auto-generated or manually created):

#[As400\Entity(table: "YOUR_TABLE")]
class YourEntity
{
    #[As400\Id]
    private int $id;

    #[As400\Column(type: "varchar", length: 50)]
    private string $name;

    // Getters/setters...
}

Repository Workflows

  • CRUD Operations:

    $repository = $this->get('as400.repository.your_entity');
    
    // Create
    $entity = new YourEntity();
    $entity->setName("Test");
    $repository->save($entity);
    
    // Read
    $entity = $repository->find(1);
    
    // Update
    $entity->setName("Updated");
    $repository->update($entity);
    
    // Delete
    $repository->delete($entity);
    
  • Query Building:

    $query = $repository->createQueryBuilder()
        ->where("name = :name")
        ->setParameter("name", "Test")
        ->getQuery();
    $results = $query->getResult();
    

Integration with Symfony Services

  • Dependency Injection:

    # config/services.yaml
    services:
        App\Service\YourService:
            arguments:
                $yourEntityRepository: '@as400.repository.your_entity'
    
  • Event Listeners:

    #[As400\EventListener]
    class YourEntityListener
    {
        public function onPrePersist(YourEntity $entity): void
        {
            // Logic before save
        }
    }
    

Gotchas and Tips

Common Pitfalls

  1. Connection Issues:

    • Ensure the ODBC driver is installed and configured on the server.
    • Verify system, user, and password in as400.yaml are correct.
    • Check firewall/network access to the AS400 system.
  2. Attribute Conflicts:

    • Avoid naming conflicts with existing Doctrine attributes (e.g., #[ORM\Id]).
    • Use fully qualified attribute names (e.g., #[Cisse\Bundle\As400\Attribute\Id]).
  3. Case Sensitivity:

    • AS400 table/column names are case-insensitive, but the bundle preserves the case as defined in the entity.

Debugging Tips

  • Query Logging: Enable in as400.yaml:

    as400:
        debug: true
    

    Logs appear in var/log/as400.log.

  • Profiler Integration: Install Symfony Profiler (symfony/profiler-pack) to visualize queries in the toolbar.

  • Command-Line Debugging: Use --verbose flag for generation commands:

    php bin/console as400:generate:entity --table=YOUR_TABLE --verbose
    

Extension Points

  1. Custom Hydrators: Override hydration logic by implementing Cisse\Bundle\As400\Hydrator\HydratorInterface.

  2. Query Builder Extensions: Extend Cisse\Bundle\As400\Repository\QueryBuilder for custom DQL functions.

  3. Event System: Listen to lifecycle events (prePersist, postLoad, etc.) via #[As400\EventListener].

Performance Tips

  • Batch Operations: Use saveMultiple() for bulk inserts/updates to reduce round-trips:

    $repository->saveMultiple([$entity1, $entity2]);
    
  • Indexed Queries: Ensure frequently queried columns are indexed in the AS400 table for better performance.

  • Connection Pooling: Configure commit_mode and extended_dynamic in as400.yaml based on workload:

    as400:
        connection:
            commit_mode: 2  # Auto-commit for read-only operations
            extended_dynamic: 0  # Disable for high-frequency writes
    
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle