Download the PHP package jtc-solutions/core without Composer
On this page you can find all versions of the php package jtc-solutions/core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jtc-solutions/core
More information about jtc-solutions/core
Files in jtc-solutions/core
Package core
Short Description Core bundle for every application in JTC that follows standard processes.
License proprietary
Informations about the package core
JTC Solutions Core Bundle
This bundle provides a foundational set of services, base classes, and conventions used as a "skeleton" for most PHP Symfony projects developed at JTC Solutions. It aims to streamline development by offering reusable components for common tasks like CRUD operations, exception handling, and API documentation.
Installation
-
Require the bundle using Composer:
- Enable the Bundle:
Add the bundle to your
config/bundles.phpfile:
Usage
-
Entities:
- Your application entities should implement
JtcSolutions\Core\Entity\IEntity. - Use
Ramsey\Uuid\UuidInterfacefor primary identifiers.
- Your application entities should implement
-
Repositories:
- Implement
JtcSolutions\Core\Repository\IEntityRepository. - Extend
JtcSolutions\Core\Repository\BaseRepository.
- Implement
-
Services:
- Implement
JtcSolutions\Core\Service\IEntityServicefor entities requiring CRUD operations. - Extend
JtcSolutions\Core\Service\BaseEntityServiceto leverage built-in logic for handling creation, updates, and deletion via abstract methods (mapDataAndCallCreate,mapDataAndCallUpdate,delete). - Inject the corresponding repository into your service.
- Implement
-
Controllers:
- Extend
JtcSolutions\Core\Controller\BaseControllerfor AbstractController from Symfony, with the possibility of future improvements. - For controllers handling standard entity CRUD, extend
JtcSolutions\Core\Controller\BaseEntityCRUDController. Inject the correspondingIEntityService. This base controller provides protected methods (handleCreate,handleUpdate,handleDelete) that validate request DTOs and call the service.
- Extend
-
Request Data Transfer Objects (DTOs):
- For request bodies used in create/update operations handled by
BaseEntityCRUDController/BaseEntityService, implementJtcSolutions\Core\Dto\IEntityRequestBody. - Use Symfony's Validator component constraints on your DTO properties.
- For request bodies used in create/update operations handled by
-
Exception Handling & Translations:
- The
ExceptionListeneris enabled by default and will catch exceptions. - It automatically converts
TranslatableExceptiontypes and standard HTTP exceptions intoErrorRequestJsonResponse. - Provide translations for the exception keys in the configured translation domain (default:
exceptions). Keys follow the patterncore.<type>.title,core.<type>.messagefor standard HTTP errors andcustom.<translation_code>.title,custom.<translation_code>.messageforTranslatableExceptiontypes. Example translation file (translations/exceptions.en.yaml):
- The
- Parameter Resolvers:
- Entity Resolver: If enabled (default), controller actions can directly type-hint arguments with an
IEntityimplementation (e.g.,public function show(Product $product)). If a route parameter{product}exists, the resolver will fetch theProductusing its repository'sfind()method. - UUID Resolver: If enabled (default), controller actions can type-hint arguments with
UuidInterface(e.g.,public function list(UuidInterface $categoryId)). The resolver will attempt to create aUuidobject from a query parameter with the same name (?categoryId=...).
- Entity Resolver: If enabled (default), controller actions can directly type-hint arguments with an
Configuration
Configure the bundle under the jtc_solutions_core key in your config/packages/jtc_solutions_core.yaml (or any other config file).
# config/packages/jtc_solutions_core.yaml
jtc_solutions_core:
# Parameter Resolver Configuration
param_resolvers:
uuid_resolver:
# Enable/disable the UuidQueryParamResolver (default: true)
enable: true
entity_resolver:
# Enable/disable the EntityParamResolver (default: true)
enable: true
# Listener Configuration
listeners:
exception_listener:
# Enable/disable the ExceptionListener (default: true)
enable: true
# Set the translation domain for exception messages (default: 'exceptions')
translation_domain: 'exceptions'
# OpenAPI / NelmioApiDocBundle Integration
open_api:
property_describers:
uuid_interface_property_describer:
# Enable/disable the describer for UuidInterface (default: true)
enable: trueAll versions of core with dependencies
symfony/framework-bundle Version 7.2.*
symfony/validator Version ^7.2
symfony/serializer Version ^7.2
symfony/http-foundation Version ^7.2
ramsey/uuid Version ^4.7
doctrine/orm Version ^3.3
jtc-solutions/helpers Version ^0.2.0
symfony/yaml Version ^7.2
symfony/translation Version ^7.2
symfony/property-info Version ^7.2
nelmio/api-doc-bundle Version ^5.0
symfony/messenger Version ^7.2