A training project demonstrating the commercetools PHP SDK in a fullstack setup using Laravel for the Backend-for-Frontend (BFF) and a lightweight frontend built with HTML, CSS, and JavaScript.
Important Note:
We are using Laravel for demonstration purposes in this project. It is not a recommendation or endorsement of Laravel over other server-side frameworks. Any other php-based server-side framework (such as Symfony, Laminas, CodeIgniter etc.) can be used to build a similar Backend-for-Frontend (BFF) layer. The choice of framework is entirely up to your preferences and project requirements.
- Learn how to use the commercetools PHP SDK in a backend service.
- Explore a simple UI that interacts with the BFF to trigger commercetools API calls.
- Practice realistic commerce use cases like product listing, cart management, and checkout flow.
- Backend: Laravel-based BFF layer.
- Frontend: Lightweight UI using HTML, CSS, and JavaScript for interacting with the backend.
- commercetools SDK: Demonstrates integrations with commercetools’ APIs.
- Provides a basic Laravel setup for interacting with commercetools APIs.
- Includes a simple frontend for triggering commerce actions (e.g., product browsing, cart management, and checkout).
- Full-stack application structure to demonstrate how to use the commercetools PHP SDK effectively.
- PHP
Laravel 10+ requires PHP 8.1 or higher. Install PHP via:
macOS: brew install php
Windows: XAMPP or WSL
- Composer
Laravel uses Composer to manage dependencies. Install it: https://getcomposer.org/download/
- Laravel
Install Laravel Installer globally:
$ composer global require laravel/installerClone this project and run composer install to install the dependencies:
$ composer installBefore running the project, you need to create an API client in the commercetools Merchant Center and provide its credentials in the .env file.
- Go to the commercetools Merchant Center.
- Create a new API client:
- Navigate to Project settings > API clients.
- Click on Create API Client and select Admin client template from drop down list.
- Make a note of the Project Key, Client ID, Client Secret and scopes.
For development:
$ php artisan serveFor viewing the frontend, plese go to http://localhost:8000
This project is licensed under the MIT License. See the LICENSE file for details.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- Simple, fast routing engine.
- Powerful dependency injection container.
- Multiple back-ends for session and cache storage.
- Expressive, intuitive database ORM.
- Database agnostic schema migrations.
- Robust background job processing.
- Real-time event broadcasting.
Laravel is accessible, powerful, and provides tools required for large, robust applications.
Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.
If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.