Installation:
composer require ccmbenchmark/ting_bundle
Register the bundle in config/bundles.php (Laravel 4.x+):
return [
// ...
CCMBenchmark\TingBundle\TingBundle::class => ['all' => true],
];
First Use Case:
Annotate an entity with metadata (e.g., src/Entity/User.php):
use CCMBenchmark\TingBundle\Annotation\Ting;
/**
* @Ting\Table(name="users")
*/
class User {}
Run php bin/console cache:clear to process annotations.
config/packages/ting.yaml (auto-generated after installation).CCMBenchmark\TingBundle\Annotation for available attributes.TingBundle is loaded in config/bundles.php.Replace YAML/XML metadata with PHP attributes (recommended for new projects):
use CCMBenchmark\TingBundle\Annotation\Ting;
class Product {
/**
* @Ting\Column(type="string", length=255)
* @Ting\Unique(name="product_code_unique")
*/
private $code;
}
Workflow:
cache:clear).TingBundle services (e.g., ting.repository_manager).Override default repository behavior via config/packages/ting.yaml:
ting:
repositories:
App:
namespace: App\Entity
directory: "%kernel.project_dir%/src/Entity"
options:
App\Entity\UserRepository:
connection: custom_db
extra:
cache_driver: redis
Integration Tip:
Use ting.repository_manager.get_repository() to fetch repositories with custom options.
Extend Symfony’s security system:
# config/packages/security.yaml
security:
providers:
ting_provider:
id: ting.security.user.provider
Workflow:
UserInterface in your entity.ting.security.user.provider in your firewall.Resolve dynamic values in API platforms:
use CCMBenchmark\TingBundle\Resolver\TingValueResolver;
class ProductController {
public function __construct(
private TingValueResolver $tingResolver
) {}
public function show(Product $product) {
$resolved = $this->tingResolver->resolve($product);
return $resolved;
}
}
Tip: Register the resolver in api_platform.metadata.factory if using API Platform.
Cache Dependency:
cache:clear after changes. Use cache:warmup in CI/CD.var/cache/dev/annotations for processed metadata.Doctrine DBAL vs. ORM:
@ORM\Entity), ensure doctrine/orm is installed.doctrine/doctrine-bundle if missing.Connection Mismatches:
connection: main fails, verify database_url in .env or config/packages/doctrine.yaml.ting.connections to define multiple DBs:
ting:
connections:
main: { url: "mysql://user:pass@localhost/db" }
replica: { url: "mysql://user:pass@replica/db" }
Metadata Dumping:
php bin/console debug:ting
Lists all registered tables, columns, and constraints.
Annotation Errors:
dev mode and check logs for Ting\Exception\MetadataException.php bin/console cache:clear --env=dev --no-debug
Custom Annotations:
Extend CCMBenchmark\TingBundle\Annotation\Ting:
namespace App\Annotation;
use Doctrine\Common\Annotations\Annotation;
/**
* @Annotation
* @Target({"CLASS", "PROPERTY"})
*/
class CustomTing extends Annotation {}
Register in services.yaml:
ting.annotation_reader:
tags: [ting.annotation_reader]
Event Listeners:
Subscribe to Ting events (e.g., TingEvents::POST_METADATA_BUILD):
use CCMBenchmark\TingBundle\Event\MetadataEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class TingSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [
TingEvents::POST_METADATA_BUILD => 'onMetadataBuild',
];
}
public function onMetadataBuild(MetadataEvent $event) {
$event->addTable('custom_table');
}
}
Namespace Conflicts:
namespace in ting.repositories is incorrect, Ting skips the directory.directory: "%kernel.project_dir%/src/Entity").Default Options:
default under options applies to all repositories unless overridden.ting:
repositories:
App:
options:
default:
connection: main
cache: true
App\Entity\AdminRepository:
cache: false
Public Properties:
@Ting\Column on public properties or make them private.How can I help you explore Laravel packages today?