Installation:
composer require anzusystems/common-bundle --no-scripts
Ensure use_putenv is enabled in composer.json for environment variables:
"extra": { "runtime": { "use_putenv": true } }
Kernel Configuration:
Update src/Kernel.php to extend AnzuKernel with required parameters:
public function __construct(
private string $appSystem,
private string $appVersion,
private bool $appReadOnlyMode,
string $environment,
bool $debug,
) {
parent::__construct($environment, $debug);
}
Update public/index.php and bin/console to pass these parameters.
Configuration:
Define config/packages/anzu_common.yaml with minimal required settings:
anzu_common:
settings:
app_redis: TestRedis
user_entity_class: App\Entity\User
app_entity_namespace: App\Entity
app_value_object_namespace: App\Model\ValueObject
First Use Case: Enable health checks and logs:
anzu_common:
health_check:
enabled: true
modules: [AnzuSystems\CommonBundle\HealthCheck\Module\OpCacheModule]
logs:
enabled: true
messenger_transport:
name: 'core_log'
dsn: '%env(MESSENGER_TRANSPORT_DSN)%?topic[name]=core_log'
anzu_common:
health_check:
enabled: true
modules:
- AnzuSystems\CommonBundle\HealthCheck\Module\MysqlModule
- AnzuSystems\CommonBundle\HealthCheck\Module\RedisModule
/health (auto-configured via AnzuKernel).anzu_common:
logs:
enabled: true
journal:
mongo:
uri: '%env(ANZU_MONGODB_APP_LOG_URI)%'
collection: appLogs
anzu_common:
logs:
audit:
mongo:
uri: '%env(ANZU_MONGODB_AUDIT_LOG_URI)%'
collection: auditLogs
logged_methods: ['POST', 'PUT', 'PATCH', 'DELETE']
dsn in messenger_transport).anzu_common:
permissions:
config:
app_article:
create: { grants: [2, 0] }
delete: { grants: [0, 1, 2] }
roles: [ROLE_USER, ROLE_ADMIN]
AbstractVoter for custom logic:
use AnzuSystems\CommonBundle\Security\Voter\AbstractVoter;
class ArticleVoter extends AbstractVoter {
protected function supports(string $attribute, $subject): bool {
return $attribute === 'edit' && $subject instanceof Article;
}
}
anzu_common:
settings:
app_value_object_namespace: App\Model\ValueObject
Money, Email) via AnzuSystems\CommonBundle\ValueObject\ValueObjectTrait.anzu_common:
settings:
unlocked_commands:
- Symfony\Component\Messenger\Command\ConsumeMessagesCommand
CurrentUserResolver or RequestParamResolver are auto-wired.use AnzuSystems\CommonBundle\Controller\ArgumentResolver\AbstractArgumentResolver;
class CustomResolver extends AbstractArgumentResolver {
public function supports(Request $request, Controller $controller): bool {
return $request->attributes->has('custom_param');
}
}
php bin/console doctrine:fixtures:load --group=test
AnzuSystems\CommonBundle\Test\Traits\TestCaseTrait for base test setups.Environment Variables:
env() in YAML or PHP for sensitive data (e.g., MongoDB URIs, Redis DSN).anzu_common:
logs:
journal:
mongo:
uri: '%env(ANZU_MONGODB_APP_LOG_URI)%'
Read-Only Mode:
appReadOnlyMode: true in Kernel constructor.AppReadOnlyModeException for write operations (handled by AppReadOnlyModeExceptionHandler).Proxy Cache:
anzu_common:
settings:
app_cache_proxy_enabled: true
Error Handling:
anzu_common:
errors:
exception_handlers:
- App\Exception\Handler\CustomHandler
Localization:
locale to User entity (v11.1.0+):
// App\Entity\User
use AnzuSystems\CommonBundle\Entity\Traits\UserTracking;
class User implements UserInterface {
use UserTracking;
// ...
}
Kernel Initialization:
AnzuKernel or pass required parameters (appSystem, appVersion, appReadOnlyMode).public/index.php and bin/console pass all constructor args.MongoDB Logs:
messenger_transport DSN.MESSENGER_TRANSPORT_DSN is set and topic is correct:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%?topic[name]=core_log'
Permission BC Breaks:
ROLE_SUPER_ADMIN instead of ROLE_ADMIN.AbstractVoter implementations:
protected function supports(string $attribute, $subject): bool {
return $this->decisionManager->decide(
$this->authenticationToken,
$subject,
$attribute
) === AccessDecisionManagerInterface::ACCESS_GRANTED;
}
Deprecated Features:
param_converters are deprecated (v7.0+). Use argument_resolvers instead.ParamConverter logic with ArgumentResolver:
// Old (deprecated)
use AnzuSystems\CommonBundle\Controller\ParamConverter\AbstractParamConverter;
// New
use AnzuSystems\CommonBundle\Controller\ArgumentResolver\AbstractArgumentResolver;
Health Check Modules:
modules are misconfigured (e.g., missing MysqlModule for MySQL checks).anzu_common:
health_check:
modules:
- AnzuSystems\CommonBundle\HealthCheck\Module\MysqlModule
- AnzuSystems\CommonBundle\HealthCheck\Module\RedisModule
Locale Field:
locale field in User entity (pre-v11.1.0).// App\Entity\User
use Doctrine\ORM\Mapping as ORM;
#[ORM\Column(type: 'string', length: 5)]
private ?string $locale = null;
Enable Debug Mode:
APP_DEBUG=1 in .env to log detailed errors.Health Check Debugging:
/health endpoint directly to see module-specific errors.{
"status": "error",
"modules": {
"mysql
How can I help you explore Laravel packages today?