Installation:
composer require cisse/as400-bundle
Register in config/bundles.php:
Cisse\Bundle\As400\As400Bundle::class => ['all' => true],
Configure Connection (config/packages/as400.yaml):
as400:
connection:
driver: "IBM i Access ODBC Driver"
system: "your-as400-system"
user: "your-username"
password: "your-password"
First Use Case:
php bin/console as400:generate:entity --table=YOUR_TABLE_NAME --entity=YourEntity
$repository = $this->get('as400.repository.your_entity');
$entity = $repository->find(1);
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...
}
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();
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
}
}
Connection Issues:
system, user, and password in as400.yaml are correct.Attribute Conflicts:
#[ORM\Id]).#[Cisse\Bundle\As400\Attribute\Id]).Case Sensitivity:
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
Custom Hydrators:
Override hydration logic by implementing Cisse\Bundle\As400\Hydrator\HydratorInterface.
Query Builder Extensions:
Extend Cisse\Bundle\As400\Repository\QueryBuilder for custom DQL functions.
Event System:
Listen to lifecycle events (prePersist, postLoad, etc.) via #[As400\EventListener].
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
How can I help you explore Laravel packages today?