Comprehensive guide for developing on EspoCRM - metadata-driven CRM with service layer architecture
EspoCRM Development covers building custom modules, entities, and integrations within the EspoCRM platform using its metadata-driven architecture. It enforces best practices such as implementing business logic exclusively in Service classes, accessing data through the ORM EntityManager, and using interface-based hooks for lifecycle events. This skill helps avoid common pitfalls like passing the Container as a dependency or embedding logic in hooks, ensuring maintainable and scalable CRM customizations.
This skill is designed for backend developers and CRM specialists working on EspoCRM customizations, particularly those responsible for creating complex business logic or integrations. Growth leads and agency strategists managing CRM automation projects can also benefit by understanding how to structure custom workflows and API extensions that align with EspoCRM’s architecture. It suits teams aiming to maintain code quality and performance while extending EspoCRM’s capabilities.
Practitioners start by setting up the development environment using EspoCRM’s extension template and organizing metadata JSON files within the module’s `Resources/metadata` directory. Next, they implement data access strictly through the EntityManager ORM, avoiding direct database queries. Business logic is encapsulated in Service classes where entities are fetched, processed, and saved. Hooks are registered via interfaces to handle lifecycle events for validation or side effects, but never for core logic. After any metadata or code changes, a cache rebuild is mandatory to apply updates correctly.
Can I write business logic inside hooks? No, hooks should only handle validation or side effects; all business logic belongs in Service classes.
Is it acceptable to access the database directly via PDO? No, all data access must go through the EntityManager ORM to maintain consistency and leverage repository patterns.
What must I do after modifying metadata JSON files? Always run the cache rebuild command (`bin/command rebuild`) to ensure EspoCRM recognizes and applies your changes.
Attach this skill to a Metaflow agent tasked with backend development or CRM automation involving EspoCRM customizations. The agent will follow the prescribed architecture by isolating business logic in Services and interacting with data exclusively via the EntityManager, ensuring robust and maintainable code. Expect workflows that include metadata editing, hook registration, and cache rebuilding to deploy effective CRM extensions. This skill integrates seamlessly with tasks requiring API endpoint creation or complex query building within EspoCRM.
For broader context, see our roundup of marketing skills claude, and read best Claude skills for marketing agencies for related setup guidance.