Download the PHP package commercetools/symfony-bundle without Composer
On this page you can find all versions of the php package commercetools/symfony-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download commercetools/symfony-bundle
More information about commercetools/symfony-bundle
Files in commercetools/symfony-bundle
Package symfony-bundle
Short Description Symfony bundle for Commercetools platform
License MIT
Informations about the package symfony-bundle
commercetools Symfony bundle Beta
The commercetools Symfony Bundle is a collection of Symfony bundles that ease the use of the commercetools PHP-SDK when implementing a Symfony project.
Table of contents
- Pre-requisites
- Installation
- Verify configuration
- Usage
- Available services
- Services list
- Console Commands
- Available console commands
- Using SDK Models in twig templates
- Available services
- Quick-start
- Disclaimer for ExampleBundle (dev)
- Testing
- Issues
- Contribute
- License
Pre-requisites
Composer : To install the composer go to https://getcomposer.org/doc/00-intro.md
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:
Next, navigate to the project's directory and run the following command:
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
Alternatively, open the composer.json file, add "commercetools/symfony-bundle"
to the require
attribute, and run
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.
or for US region change URLs to
For more information about using .env
and .env.local
, see
here and
here
Verify configuration
To verify that your configuration works, after adding your client credentials on the .env
file
run the following on the command line:
If everything is set up correctly, this should return the details of your project. For example:
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
- Dependency:
- ReviewBundle
- SetupBundle
- Dependency:
symfony/console
- Dependency:
- ShoppingListBundle
- StateBundle
- Dependency:
symfony/console
,symfony/workflow
,twig/extensions
- Dependency:
By default, CtpBundle
& CustomerBundle
are enabled for all environments.
SetupBundle
& 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
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:
Services list
- CartBundle: Provides helpers for carts, orders, payments and shipping-methods
- CartManager
- OrderManager
- PaymentManager
- ShippingMethodManager
- CatalogBundle: Provides helpers for products, product-types, product-projections,
categories, product search and facets
- CatalogManager
- Search
- CtpBundle: Provides the core helpers required by the rest bundles. Includes the HTTP client
factory, the custom-type-provider for handling custom-types, the locale converter,
the mapper factory and the context factory
- ClientFactory
- ContextFactory
- MapperFactory
- LocaleConverter
- CustomTypeProvider
- CustomerBundle: Provides user and customer related features including an integrated
authentication provider
- CustomerManager
- AuthenticationProvider
- UserProvider
- ReviewBundle: Provides helpers for reviews
- ReviewManager
- ShoppingListBundle: Provides helpers for shopping-lists
- ShoppingListManager
- StateBundle: Provides helpers for handling the state of LineItems, Orders, Payments, Products
and Reviews. It can be configured as a
workflow
or as astate_machine
and takes care of the transition between the states.- CtpMarkingStoreLineItemState
- CtpMarkingStoreOrderState
- CtpMarkingStorePaymentState
- CtpMarkingStoreProductState
- CtpMarkingStoreReviewState
Console Commands
SetupBundle
and StateBundle
come together with a few handy console commands. These commands
automate tasks during development and allow a 2-way sync between an online project and a local configuration.
To use a console command navigate to your project's directory and run
Available console commands
-
SetupBundle
bin/console commercetools:project-info
: Fetches and displays information from commercetools platform about the selected projectbin/console commercetools:project-apply-configuration
: Save the local project configuration that resides undercommercetools
key, on the online commercetools platformbin/console commercetools:create-custom-type
: Interactive CLI to create CustomTypes on your projectbin/console commercetools:sync-custom-types-from-server
: Saves locally the CustomTypes currently present on the online project, in the<PROJECT_DIR>/config/packages/<ENV>/custom_types.yaml
filebin/console commercetools:sync-custom-types-from-local
: Saves or updates the CustomTypes present locally in the<PROJECT_DIR>/config/packages/<ENV>/custom_types.yaml
file, on your online commercetools project
-
StateBundle
bin/console commercetools:set-state-machine-config
: Fetches States from commercetools platform and creates a Symfonystate_machine
type configuration file at<PROJECT_DIR>/config/packages/<ENV>/workflow.yaml
-
bin/console commercetools:set-workflow-config
: Fetches States from commercetools platform and creates a Symfonyworkflow
type configuration file at<PROJECT_DIR>/config/packages/<ENV>/workflow.yaml
More info on working with Symfony Workflows can be found in Symfony's documentation:
Using SDK Models in twig templates
If you are using Twig for your templating engine you can print the value of a nested attribute of any SDK Model just by referring the attribute's path and name. For example the following two are valid representations:
Quick-start
For a more detailed quick start guide you can continue here
Disclaimer for ExampleBundle (dev)
There is an ExampleBundle provided in the repository which tries to demonstrate a sample eshop implementation making use of the other Bundles provided. This ExampleBundle is currently under development. It may includes outdated code, is not properly tested and right now is not encouraged to be used in any production environment. For now, we don't guarantee any non breaking changes. We intend to fix the problems, improve it and create a more helpful generic example.
Testing
Clone the project and navigate on the project's directory. On the command line, run
Issues
Check current issues or open a new one
Contribute
Contribute
License
This bundle is under the MIT license. See the complete license in the bundle: MIT License
All versions of symfony-bundle with dependencies
symfony/framework-bundle Version ^3.4 | ^4.0
symfony/form Version ^3.4 | ^4.0
symfony/templating Version ^3.4 | ^4.0
symfony/security-bundle Version ^3.4 | ^4.0
symfony/validator Version ^3.4 | ^4.0
symfony/serializer Version ^3.4 | ^4.0
symfony/cache Version ^3.4 | ^4.0
commercetools/php-sdk Version ^2.6
symfony/var-dumper Version ^3.4 | ^4.0
symfony/dotenv Version ^3.4 | ^4.0
symfony/stopwatch Version ^3.4 | ^4.0
symfony/workflow Version ^3.4 | ^4.0
twig/extensions Version ^1.5
symfony/console Version ^3.4 | ^4.0
symfony/twig-bundle Version ^3.4 | ^4.0
squizlabs/php_codesniffer Version ^3.4