PHPackages                             commercetools/symfony-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. commercetools/symfony-bundle

AbandonedArchivedSymfony-bundle[Framework](/categories/framework)

commercetools/symfony-bundle
============================

Symfony bundle for Commercetools platform

0.4.7(7y ago)1019.8k6[5 issues](https://github.com/commercetools/commercetools-php-symfony/issues)MITPHPPHP &gt;=7.0

Since Jul 25Pushed 6y ago12 watchersCompare

[ Source](https://github.com/commercetools/commercetools-php-symfony)[ Packagist](https://packagist.org/packages/commercetools/symfony-bundle)[ RSS](/packages/commercetools-symfony-bundle/feed)WikiDiscussions develop Synced 4w ago

READMEChangelogDependencies (22)Versions (20)Used By (0)

commercetools Symfony bundle Beta
=================================

[](#commercetools-symfony-bundle-beta)

The commercetools Symfony Bundle is a collection of Symfony bundles that ease the use of the [commercetools PHP-SDK](https://github.com/commercetools/commercetools-php-sdk) when implementing a Symfony project.

##### Table of contents

[](#table-of-contents)

- [Pre-requisites](#pre-requisites)
- [Installation](#installation)
    - [Verify configuration](#verify-configuration)
- [Usage](#usage)
    - [Available services](#available-services)
        - [Services list](#services-list)
    - [Console Commands](#console-commands)
        - [Available console commands](#available-console-commands)
    - [Using SDK Models in twig templates](#using-sdk-models-in-twig-templates)
- [Quick-start](#quick-start)
- [Disclaimer for ExampleBundle (dev)](#disclaimer-for-examplebundle--dev-)
- [Testing](#testing)
- [Issues](#issues)
- [Contribute](#contribute)
- [License](#license)

Pre-requisites
--------------

[](#pre-requisites)

Composer : To install the composer go to

Installation
------------

[](#installation)

You can either create a new Symfony project or use an existing Symfony project (ver. 3.4 and above)

Create a new Symfony project using the following command:

```
composer create-project symfony/skeleton
```

Next, navigate to the project's directory and run the following command:

```
composer config extra.symfony.allow-contrib true
```

This automates most of the configuration using the `recipes-contrib` bundle from Symfony Flex.

Next, install the commercetools Symfony bundle. To do this, run the following from the command line

```
composer require commercetools/symfony-bundle
```

Alternatively, open the **composer.json** file, add `"commercetools/symfony-bundle"` to the `require` attribute, and run

```
composer install
```

Next, open the`.env` file or create a `.env.local` file on root directory and edit the following lines to add your credentials. You can retrieve your API client credentials from the Merchant Center under `Commercetools Merchant Center > Settings > Developer Settings`, when you create a new API Client. Note that for security reasons you cannot retrieve the `CTP_CLIENT_SECRET`for clients created in the past.

```
CTP_CLIENT_ID=
CTP_CLIENT_SECRET=
CTP_PROJECT_KEY=
CTP_AUTH_URL=https://auth.commercetools.com
CTP_API_URL=https://api.commercetools.com
CTP_SCOPES=
```

or for US region change URLs to

```
CTP_AUTH_URL=https://auth.commercetools.co
CTP_API_URL=https://api.commercetools.co
```

For more information about using `.env` and `.env.local`, see [here](https://symfony.com/doc/current/configuration/dot-env-changes.html) and [here](https://symfony.com/blog/new-in-symfony-4-2-define-env-vars-per-environment)

### Verify configuration

[](#verify-configuration)

To verify that your configuration works, after adding your client credentials on the `.env` file run the following on the command line:

```
bin/console commercetools:project-info
```

If everything is set up correctly, this should return the details of your project. For example:

```
Project's key: super-cool-project-4
Project's name: my eshop at commercetools
Countries: DE, US
Currencies: EUR
Languages: en
Created at: 2019-02-04T11:28:49+00:00
Messages: disabled

```

Usage
-----

[](#usage)

The commercetools Symfony bundle consists of 8 smaller bundles (The dependencies mentioned are only the additional ones, required for bundle-specific functionalities)

- CartBundle
- CatalogBundle
- CtpBundle
- CustomerBundle
    - Dependency: `symfony/security-bundle`
- ReviewBundle
- SetupBundle
    - Dependency: `symfony/console`
- ShoppingListBundle
- StateBundle
    - Dependency: `symfony/console`, `symfony/workflow`, `twig/extensions`

By default, `CtpBundle` &amp; `CustomerBundle` are enabled for all environments. `SetupBundle` &amp; `StateBundle` are only enabled for for development environments. To see which bundles are enabled and optionally enable or disable them, edit the `config/bundles.php` file.

### Available services

[](#available-services)

The main idea is that in each Bundle there are some reusable services that you may inject directly in your app. As a generic pattern there are a couple of `*Manager` services, that provide related actions. So, for example in `CartManager`you will find helpers like `getCart`, `createCartForUser` and `update`. The `update` service returns a `CartUpdateBuilder` where you can dynamically build update actions. To autowire a service, for example `CatalogManager`, in a controller action, do the following:

```
