Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
   eZ Publish 4.x / legacy

eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


The public API will give you an easy access to the eZ Publish content repository. This repository is the core component that manages content, locations (former Nodesnodes in eZ Publish 4.x), sections, content types (former Content Classes in eZ Publish 4.x), users, user groups, users and roles. It also provides a new, clear interface for plugging in custom field types (former Datatypesdatatypes in eZ Publish 4.x).
The public API is built on top of a layered architecture including a new persistence layer for abstracting the storage functionalitypersistence API that abstracts storage. By using the public API, you are sure that your applications code will be forward compatible with future releases based on enhanced,  scalable and high-performance storage engines. Applications based on the public API are also fully backwards compatible by using the included storage engine based on the current kernel and database model.


Getting Started

Recipe 1 - Setting up a sample command line symfony bundle using the public API

This recipe shows a good practice how to use the public API inside the eZ Publish 5 installation by using the symfony console component. Inside the cookbook,  all code runs inside a symfony command which is inside a symfony bundle. It is now shown how to setup a simple symfony bundle with a commandline script using the public API. The command is executable within the ezpublish/console and dumps a content object for a given content id.

Go to the eZ publish installation

cd <ezpublish installation root>

Generate a new Bundle

php ezpublish/console generate:bundle

Now follow the instructions. This will create a bundle EzSystems/CookBookBundle in the src directory of the installation root (Note: this bundle exists already so a different namespace will be required).




Symfony bundle

In order to test and use Public API code, you will need to build a custom bundle. Bundles are Symfony's extensions, and are therefore also used to extend eZ Publish. Symfony 2 provides code generation tools that will let you create your own bundle and get started in a few minutes.

In this chapter, we will show how to create a custom bundle, and implement both a command line script and a custom route with its own controller action and view. All shell commands assume that you use some linux shell, but those commands would of course also work on windows systems.

Generating a new bundle

First, change directory to your eZ Publish root.

Code Block
$ cd /path/to/ezpublish

Then use the app/console application, with the generate:bundle command to start the bundle generation wizard

Code Block
$ php ezpublish/console generate:bundle

Let's follow the instructions provided by the ward. Our objective is to create a bundle named EzSystems/Bundles/CookBookBundle, located in the src directory.

The wizard will first ask about our bundle's namespace. Each bundle's namespace should feature a vendor name (in our own case: EzSystems), optionally followed by a sub-namespace (we choose to use Bundle in order to follow the kernel's conventions), and end with the actual bundle's name, suffixed with Bundle: CookbookBundle.

Code Block
titleBundle namespace
Your application code must be written in bundles. This command helps you generate them easily.

Each bundle is hosted under a namespace (like Acme/Bundle/BlogBundle).

The namespace should begin with a "vendor" name like your company name, your project name, or your client name, followed by one or more optional category sub-namespaces, and it should end with the bundle name itself (which must have Bundle as a suffix).

See for more details on bundle naming conventions.

Use / instead of \  for the namespace delimiter to avoid any problem.

Bundle namespace: EzSystems/BundlesBundle/CookbookBundle

You will then be asked about the Bundle's name, used to reference your bundle in your code. We can go with the default, EzSystemsCookbookBundle. Just hit enter to accept the default.

Code Block
titleBundle name
In your code, a bundle is often referenced by its name. It can be the concatenation of all namespace parts but it's really up to you to come up with a unique name (a good practice is to start with the vendor name).

Based on the namespace, we suggest EzSystemsCookbookBundle.

Bundle name [EzSystemsCookbookBundle]: 

The bundle can be generated anywhere. The suggested default directory uses
the standard conventions.

Target directory [.../ezpublish5/src]: 

Determine the format to use for the generated configuration.

Configuration format (yml, xml, php, or annotation) [annotation]: yml

To help you get started faster, the command can generate some
code snippets for you.

Do you want to generate the whole directory structure [no]? yes

  Summary before generation  

You are going to generate a "EzSystems\CookbookBundle\EzSystemsCookBookBundle" bundle
in ".../ezpublish5/src/" using the "yml" format.

Do you confirm generation [yes]? yes

  Bundle generation  

Generating the bundle code: OK
Checking that the bundle is autoloaded: OK
Confirm automatic update of your Kernel [yes]? yes  
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? yes
Importing the bundle routing resource: OK

  You can now start using the generated code!  

Add a Command directory to the bundle