ibexa/core
Ibexa Core is the foundation of the Ibexa DXP, providing the PHP domain model, repository API, content types, users, permissions, search, and persistence layer integrations. It powers content management features and serves as the base for higher-level Ibexa packages.
Installation:
composer require ibexa/core
For Symfony integration, follow the official docs.
First Use Case: Fetch and render a content item in a controller:
use Ibexa\Contracts\Core\Repository\Repository;
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
public function showContent(Repository $repository, int $contentId): Response
{
$contentService = $repository->getContentService();
$content: Content = $contentService->load($contentId);
return $this->render('content/show.html.twig', [
'content' => $content,
]);
}
Key Entry Points:
$repository = $container->get('ibexa.repository')).$repository->getContentService()).$repository->getSearchService()).{{ ibexa.render(content) }} in templates.Configuration:
Override default settings in config/packages/ibexa.yaml:
ibexa:
system:
default:
content_types:
group_name: 'YourGroup'
Create/Update Content:
$contentService = $repository->getContentService();
$contentCreateStruct = $contentService->newContentCreateStruct('article');
$contentCreateStruct->setField('title', 'My Article');
$content = $contentService->create($contentCreateStruct, $parentLocationId);
$contentService->publishVersion($content->versionInfo);
Bulk Operations:
Use ContentService::load() + ContentService::update() in loops, or leverage the Content API for complex logic.
Field Handling:
$field = $content->getField('image');
$fieldValue = $field->value; // For simple fields
$binaryFile = $field->getBinaryFile(); // For binary fields (e.g., images)
Basic Search:
$searchService = $repository->getSearchService();
$query = new Query\Query();
$query->query = new Query\Criteria\Query();
$query->query->filter = new Query\Criteria\Filter\Operator\Equals\ContentType('article');
$searchResult = $searchService->findContent($query);
Advanced Criteria: Combine filters, sorting, and aggregations:
$query->query->filter = new Query\Criteria\LogicalAnd([
new Query\Criteria\Filter\Operator\Equals\ContentType('article'),
new Query\Criteria\Filter\Operator\Equals\ContentLanguage('eng-GB'),
]);
$query->query->sortClauses = [
new Query\Criteria\SortClause\Content\DatePublished(Query\Criteria\SortClause\SortClause::DIRECTION_DESC),
];
Embedding Search (v5+):
$embeddingSearchService = $repository->getEmbeddingSearchService();
$results = $embeddingSearchService->search('query text', 5);
$locationService = $repository->getLocationService();
$children = $locationService->load($parentLocationId)->getChildren();
$locationService->move($content->getLocation(), $newParentLocationId);
$securityService = $repository->getSecurityService();
if ($securityService->checkPolicy($content, 'read')) {
// Granted
}
$userService = $repository->getUserService();
$user = $userService->loadUser('admin');
$userService->assignRole($user, $role, $content);
{{ ibexa.render(content, {
'viewType': 'full',
'template': 'content/teaser.html.twig'
}) }}
{% set image = ibexa.field(content, 'image') %}
<img src="{{ ibexa.image(image, 'original') }}" alt="{{ image.alt }}">
php bin/console ibexa:io:migrate-files
Ibexa\Core\Base\IbexaCommand and inject the Repository:
protected function execute(InputInterface $input, OutputInterface $output): int
{
$repository = $this->getContainer()->get('ibexa.repository');
// Logic here
}
services:
App\Service\MyService:
tags: ['ibexa.content_type']
ContentPublish, ContentUnpublish):
use Ibexa\Core\Event\Content\PublishEvent;
public function onContentPublish(PublishEvent $event): void
{
$content = $event->getContent();
// Logic
}
Ibexa\Core\FieldType\FieldType and register in services.yaml:
Ibexa\Core\FieldType\FieldTypeCollection:
arguments:
- '@App\FieldType\MyFieldType'
ibexa:
storage:
default:
external_storage:
s3:
enabled: true
bucket: 'my-bucket'
endpoint: 's3.amazonaws.com'
Ibexa\Core\Api\ApiResource annotations:
use Ibexa\Core\Api\ApiResource;
#[ApiResource]
class ArticleController extends AbstractController
{
#[Get('/articles/{id}')]
public function getArticle(int $id): Content
{
return $this->repository->getContentService()->load($id);
}
}
SiteAccess Context:
SiteAccess context can lead to unexpected behavior (e.g., wrong language or content visibility).$repository->setCurrentSiteAccess('site1');
dd($repository->getCurrentSiteAccess()) to verify.Content Versioning:
$contentService->loadDraft($contentId);
Field Value Serialization:
Field::value for simple fields, Field::getBinaryFile() for binaries.Search Indexing:
php bin/console ibexa:search:reindex
Circular References:
$location->getChildren(['limit' => 10]);
Twig Caching:
{{ ibexa.render(content, {'cache' => false}) }}.Permission Inheritance:
SecurityService::setPolicy() carefully and test inheritance chains.Enable Debug Mode:
ibexa:
debug: true
Query Logging:
How can I help you explore Laravel packages today?