Guidelines for AI coding agents working on the AssetConnect (maniaba/asset-connect) repository.
| Item | Value |
|---|---|
| Type | PHP library (CodeIgniter 4) |
| Namespace | Maniaba\AssetConnect |
| PHP version | ^8.3 |
| Framework | CodeIgniter ^4.6 + CodeIgniter Queue ^1.0 |
| Tests | PHPUnit 10/11/12 |
| Static analysis | PHPStan (strict) + Psalm |
| Style | PSR-12 + CodeIgniter coding standard |
| Migration | php spark migrate --namespace=Maniaba\\AssetConnect |
src/ Library source code (see docs/module-structure.md)
tests/ PHPUnit test suite
tests/_support/ Factories, fixtures, mock implementations
docs/ MkDocs documentation
.github/workflows/ CI workflows (phpunit, phpstan, psalm, deptrac, docs)
For a detailed breakdown of every module see docs/module-structure.md.
For AI-context summary see .ai/context.md.
composer installNo database server is required for the test suite (uses vfsstream + SQLite in-memory where needed).
| Purpose | Command |
|---|---|
| Run tests | composer test |
| Run with coverage | composer test -- --coverage-html=build/coverage |
| Static analysis | composer analyze |
| Fix code style | composer cs-fix |
| Check code style (dry-run) | composer cs |
| Deptrac layer check | composer inspect |
| Full CI pipeline | composer ci |
| Mutation testing | composer mutate |
declare(strict_types=1)at the top of every PHP file.- Use
finalfor all concrete classes that are not intended for extension. - Implement extension points through interfaces and traits, not inheritance.
- Never use
mixedwhen a specific type can be expressed. - Docblocks are only required when the signature alone is ambiguous.
- All public API changes must be accompanied by tests.
composer cs-fix– fix code style.composer test– all tests must pass.composer analyze– no new PHPStan or Psalm errors.composer inspect– Deptrac must not report new violations.- If a new collection, entity, or configuration option is added, update
docs/accordingly.
When preparing a release, update the version in these three places:
src/AssetConnect.php– updateAssetConnect::VERSION.CHANGELOG.md– promote the top release section to## [vX.Y.Z](https://github.com/maniaba/asset-connect/tree/vX.Y.Z) - YYYY-MM-DD.docs/index.md– update the documentation title and introductory version text.
Do not add a version field to composer.json; this package is versioned from Git tags.
Any new entity or collection added to the library examples or tests must be listed in Config\Asset:
public array $entityKeyDefinitions = [MyEntity::class => 'my_entity'];
public array $collectionKeyDefinitions = [MyCollection::class => 'my_collection'];Failure to register will cause a runtime error.
- Create a class in
src/AssetCollection/(or app-space for consumer examples). - Implement
AssetCollectionDefinitionInterface(+AssetVariantsInterfaceand/orAuthorizableAssetCollectionDefinitionInterfaceas needed). - Register in config.
- Add tests under
tests/.
- Implement
PathGeneratorInterface(getPath(Asset): string). - Set via
$setup->setPathGenerator()or$config->defaultPathGenerator.
- Implement
UrlGeneratorInterface. - Set via
$config->defaultUrlGenerator.
- Implement
PendingStorageInterface. - Set via
$config->pendingStorage.
- Mirror the
src/directory structure intests/. - Use
mikey179/vfsstreamfor filesystem interactions. - Use
FakerPHPfor generating test data. - Mock only at architectural boundaries (interfaces), not internal classes.
- Do not remove or weaken existing tests.
- Never expose the raw filesystem path in responses; always use
Asset::getUrl(). - Private assets must go through the authorisation controller; implement
AuthorizableAssetCollectionDefinitionInterface. - Temporary URL tokens are HMAC-signed; do not bypass
TempUrlToken. - Do not commit secrets or credentials.
- Changes to CI4 core or CodeIgniter Queue internals.
- Adding non-PHP runtimes or build tools.
- Breaking changes to the public API without a corresponding CHANGELOG entry and version bump.