• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    PHP
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Shop API for Sylius.

Sylius Shop API

License Build Status Scrutinizer Quality Score

This repository contains a plugin that extends the Sylius eCommerce platform with an API in JSON that allows performing all standard shop operations from the customer perspective.

Documentation

The latest documentation is available here. If you are looking for more information how the system works have a look at the cookbook

Installation

IMPORTANT NOTE: Before installing SyliusShopApiPlugin, you should disable all SyliusShopBundle's dependencies. You cannot use these packages together.

  1. Run composer require sylius/shop-api-plugin and, when asked if you want to execute the Flex recipe, answer 'Yes'.

  2. Extend config files:

    1. Add SyliusShopApi to config/bundles.php.
    // config/bundles.php
    
        return [
            Sylius\ShopApiPlugin\SyliusShopApiPlugin::class => ['all' => true],
        ];
    1. Add - { path: '^/shop-api', priorities: ['json'], fallback_format: json, prefer_extension: true } to fos_rest.format_listener.rules section in config/packages/fos_rest.yaml file and import config from Plugin.
    # config/packages/_sylius_shop_api.yaml
    
    imports: # <-- Add this section if it does not already exist and add the lines below
        # ...
        - { resource: "@SyliusShopApiPlugin/Resources/config/app/config.yml" }
        - { resource: "@SyliusShopApiPlugin/Resources/config/app/sylius_mailer.yml" }
    
    # config/packages/fos_rest.yaml
    
    fos_rest:
        # ...
        
        format_listener:
            rules:
                - { path: '^/shop-api', priorities: ['json'], fallback_format: json, prefer_extension: true } # <-- Add this
                - { path: '^/api', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
                - { path: '^/', stop: true }
    
    1. Add new routes file to import routes from the SyliusShopApiPlugin
    # config/routes/sylius_shop_api.yaml
    
    sylius_shop_api:
        resource: "@SyliusShopApiPlugin/Resources/config/routing.yml"
    1. Configure firewall

      1. Change sylius.security.shop_regex parameter to exclude shop-api prefix also
      2. Add ShopAPI regex parameter sylius_shop_api.security.regex: "^/shop-api"
      3. Add ShopAPI firewall config:
        • Symfony 6:

          # config/packages/security.yaml
          
          parameters:
              # ...
          
              sylius.security.shop_regex: "^/(?!admin|api/.*|api$|shop-api|media/.*)[^/]++" # shop-api has been added inside the brackets
              sylius_shop_api.security.regex: "^/shop-api"
          
          # ... 
          
          security:
              firewalls:
                  // ...
          
                  sylius_shop_api:
                      pattern: "%sylius_shop_api.security.regex%"
                      stateless: true
                      entry_point: jwt
                      provider: sylius_shop_user_provider
                      json_login:
                          check_path: /shop-api/login
                          username_path: email
                          password_path: password
                          success_handler: lexik_jwt_authentication.handler.authentication_success
                          failure_handler: lexik_jwt_authentication.handler.authentication_failure
                      jwt: true
             access_control:
             - { path: "%sylius_shop_api.security.regex%/address-book", role: ROLE_USER}
             - { path: "%sylius_shop_api.security.regex%/me", role: ROLE_USER}
        • Symfony 5:

          # config/packages/security.yaml
          
          parameters:
              # ...
          
              sylius.security.shop_regex: "^/(?!admin|api/.*|api$|shop-api|media/.*)[^/]++" # shop-api has been added inside the brackets
              sylius_shop_api.security.regex: "^/shop-api"
          
          # ... 
          
          security:
              firewalls:
                  // ...
          
                  sylius_shop_api:
                      pattern: "%sylius_shop_api.security.regex%"
                      stateless: true
                      anonymous: true
                      provider: sylius_shop_user_provider
                      json_login:
                          check_path: /shop-api/login
                          username_path: email
                          password_path: password
                          success_handler: lexik_jwt_authentication.handler.authentication_success
                          failure_handler: lexik_jwt_authentication.handler.authentication_failure
                      guard:
                          authenticators:
                              - lexik_jwt_authentication.jwt_token_authenticator
             access_control:
             - { path: "%sylius_shop_api.security.regex%/address-book", role: ROLE_USER}
             - { path: "%sylius_shop_api.security.regex%/me", role: ROLE_USER}
    2. (optional) if you have installed nelmio/NelmioCorsBundle for Support of Cross-Origin Ajax Request,

      1. Add the NelmioCorsBundle to the AppKernel
      // config/bundles.php
      
      return [
          Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
      ];
      1. Add the new configuration file
      # config/packages/nelmio_cors.yml
      
      # ...
      
      nelmio_cors:
          defaults:
              allow_credentials: false
              allow_origin: []
              allow_headers: []
              allow_methods: []
              expose_headers: []
              max_age: 0
              hosts: []
              origin_regex: false
              forced_allow_origin_value: ~
          paths:
              '^/shop-api/':
                  allow_origin: ['*']
                  allow_headers: ['Content-Type', 'authorization']
                  allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'PATCH', 'OPTIONS']
                  max_age: 3600
  3. Follow https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.rst#installation

Sample configuration of Shop API can be found here: https://github.com/Sylius/SyliusDemo/commit/4872350dcd6c987d54dec1f365b4bb890d7183c9

Additional features

Attributes

If you would like to receive serialized attributes you need to define an array of theirs codes under sylius_shop_api.included_attributes key. E.g.

# config/packages/sylius_shop_api.yml
sylius_shop_api:
    included_attributes:
        - "MUG_MATERIAL_CODE"

This plugin comes with an integration with LexikJWTAuthenticationBundle. More information about security customizations may be found there.

Testing

The application can be tested with API Test Case. In order to run test suite execute the following commands:

$ cp tests/Application/.env.test.dist tests/Application/.env.test
$ set -a && source tests/Application/.env.test && set +a
$ (cd tests/Application && bin/console doctrine:database:create -e test)
$ (cd tests/Application && bin/console doctrine:schema:create -e test)

$ vendor/bin/phpunit

The application can be also tested with PHPSpec:

$ vendor/bin/phpspec run

Security issues

If you think that you have found a security issue, please do not use the issue tracker and do not post it publicly. Instead, all security issues must be sent to [email protected].

Maintenance

This library is officially maintained by Sylius together with the following contributors outside of the organization:

Release cycle

This projects follows Semantic Versioning. Shop API release cycle is independent from Sylius release cycle.

Next major releases are not planned yet. Minor and patch releases will be published as needed.

We provide bug fixes only for the most recent minor release. We provide security fixes for one year since the release of subsequent minor release.

Supported versions

Version Release date End of support
1.0 23rd Nov 2019 19th June 2021
1.1 19th June 2020 08th December 2020
1.2 08th December 2020 22th April 2021
1.2.1 22th April 2021 22th April 2021
1.3 22th April 2021 22th April 2021
1.3.1 22th April 2021 30th June 2021
1.4 30th June 2021 06th July 2021
1.4.1 06th July 2021 20th July 2022
1.5 20th July 2022 21th July 2022
1.5.1 21th July 2022 13th January 2023
1.6 13th January 2023

More Repositories

1

Sylius

Open Source eCommerce Framework on Symfony
PHP
7,646
star
2

Sylius-Standard

Open Source eCommerce Application on top of Symfony
PHP
231
star
3

SyliusResourceBundle

Simpler CRUD for Symfony applications
PHP
208
star
4

SyliusGridBundle

Generic data grids for Symfony applications, support Doctrine and custom drivers, sorting, filtering, actions and field types.
PHP
104
star
5

SyliusCartBundle

DEPRACATED. See Sylius/Sylius repository.
PHP
104
star
6

SyliusThemeBundle

Theming for Symfony, supports templates, assets and translations.
PHP
90
star
7

SyliusFlowBundle

[READ-ONLY] Multi step actions, suitable for building checkouts or setups.
PHP
84
star
8

InvoicingPlugin

Generate an Invoice for every placed order
PHP
80
star
9

Sylius-Sandbox

[DEPRACATED] Sylius sandbox application, playground and testing place for Sylius and Symfony2 beginners.
PHP
77
star
10

PluginSkeleton

Skeleton for starting Sylius plugins.
PHP
71
star
11

SyliusMailerBundle

Simple e-mails sending!
PHP
69
star
12

RefundPlugin

Basic refunds functionality for Sylius
PHP
64
star
13

Registry

Registry component.
PHP
59
star
14

AdminOrderCreationPlugin

Create orders in Sylius as an Administrator
PHP
56
star
15

Sylius-Docs

DEPRACATED. See Sylius/Sylius repository.
54
star
16

SyliusFixturesBundle

Configurable fixtures for Symfony applications.
PHP
49
star
17

Docker

Docker scripts for Sylius.
Makefile
43
star
18

SyliusDemo

Official Sylius demo application.
PHP
40
star
19

RbacPlugin

Sylius roles and permissions management plugin
PHP
33
star
20

SyliusAddressingBundle

[READ-ONLY] Addresses, countries, states and zones management for Symfony2.
PHP
33
star
21

PayPalPlugin

Official integration with PayPal Commerce Platform
PHP
33
star
22

Promotion

[READ-ONLY] Flexible promotions engine for PHP e-commerce applications.
PHP
27
star
23

SyliusTaxonomyBundle

[READ-ONLY] Taxonomies for Symfony2 applications.
PHP
26
star
24

Resource

[READ-ONLY] Resource management abstraction for PHP.
PHP
23
star
25

SyliusCoreBundle

[READ-ONLY] Subtree split of the Sylius core - please see "Sylius" repository.
PHP
22
star
26

CustomerOrderCancellationPlugin

Plugin that allows customers to cancel the placed order before it is processed.
PHP
22
star
27

SyliusPaymentBundle

[READ-ONLY] Gateway agnostic payments engine for Symfony2.
PHP
22
star
28

Order

[READ-ONLY] Orders management component for PHP e-commerce apps.
PHP
21
star
29

SyliusThemingBundle

Bundle that provides theming feature.
PHP
21
star
30

SyliusSettingsBundle

[READ-ONLY] Flexible settings system (with web UI) for Symfony2 applications.
PHP
21
star
31

Product

[READ-ONLY] Product catalog for PHP.
PHP
21
star
32

SyliusAssortmentBundle

DEPRACATED. Use SyliusProductBundle and its extensions instead.
PHP
21
star
33

CustomerReorderPlugin

Plugin that allows customers to reorder previously placed order.
PHP
20
star
34

SyliusInventoryBundle

[READ-ONLY] Flexible inventory management for Symfony2 e-commerce applications.
PHP
19
star
35

SyliusMoneyBundle

[READ-ONLY] Currency and money handling for Symfony2 apps.
PHP
18
star
36

SyliusPromotionBundle

[READ-ONLY] Flexible promotions system - time promotions, coupons, custom actions, rules for your Symfony2 ecommerce app.
PHP
18
star
37

SyliusSalesBundle

[READ-ONLY] Orders engine for Symfony2 e-commerce solutions.
PHP
18
star
38

Vagrant

[ABANDONED] Vagrant development environment for Sylius.
Shell
17
star
39

SyliusOmnipayBundle

[READ-ONLY] Symfony2 integration with Omnipay - payment processing library for PHP.
PHP
17
star
40

SyliusTaxationBundle

[READ-ONLY] Customizable taxation system for Symfony2 e-commerce applications.
PHP
17
star
41

SyliusProductBundle

[READ-ONLY] Product catalog bundle for Symfony
PHP
16
star
42

Payment

[READ-ONLY] Basic payment models and architecture for PHP e-commerce projects.
PHP
16
star
43

SyliusCategorizerBundle

DEPRACATED.
PHP
15
star
44

Taxonomy

[READ-ONLY] Categorization component for PHP.
PHP
14
star
45

SyliusPluginsBundle

Installable plugins bundle for Symfony2 applications.
PHP
14
star
46

Mailer

[READ-ONLY] Sylius mailer component.
PHP
14
star
47

SyliusShippingBundle

[READ-ONLY] Shipments, shipping methods and categories management for Symfony2.
PHP
14
star
48

Cart

[READ-ONLY] Webshop cart library for PHP.
PHP
14
star
49

ThemeSkeleton

Starting point for new themes.
HTML
13
star
50

SyliusBloggerBundle

DEPRACATED.
PHP
13
star
51

SyliusWebBundle

DEPRACATED. See Sylius/Sylius repository.
HTML
13
star
52

Rbac

[READ-ONLY] Sylius Hierarchical Role Based Access Control component.
PHP
12
star
53

Shipping

[READ-ONLY] Shipments, shipping method and charges library for PHP e-commerce.
PHP
12
star
54

SyliusAdminApiBundle

Administration REST API for Sylius eCommerce.
PHP
11
star
55

SyliusPayumBundle

[READ-ONLY] Sylius integration with Payum payments library.
PHP
11
star
56

SyliusRbacBundle

[READ-ONLY] Sylius Hierarchical Role Based Access Control integration with Symfony2.
PHP
11
star
57

SyliusOrderBundle

[READ-ONLY] Orders engine for Symfony2 e-commerce solutions.
PHP
11
star
58

Core

[READ-ONLY] Sylius e-commerce core.
PHP
10
star
59

Sylius-Docker-Standard

Dockerfile
10
star
60

SyliusPricingBundle

Resolving object prices...
PHP
10
star
61

Taxation

[READ-ONLY] Taxation system with multiple categories and rates support, for PHP.
PHP
10
star
62

Locale

[READ-ONLY] Locales management component for PHP apps.
PHP
10
star
63

PriceHistoryPlugin

Implementation of "Directive (EU) 2019/2161 of the European Parliament and of the Council", also known as the "Omnibus Directive".
PHP
10
star
64

Grid

[READ-ONLY] Generic Grid component that allows you to manage fields, sorting, filters and actions for grids of data.
PHP
9
star
65

Calendar

Date handling for PHP applications.
PHP
9
star
66

docker-nginx-php-fpm

Sylius nginx+php-fpm base image suitable to run Sylius Standard
Makefile
9
star
67

SyliusAttributeBundle

[READ-ONLY] Attribute handling for Symfony2 business entities.
PHP
9
star
68

Inventory

[READ-ONLY] Inventory management component for PHP.
PHP
8
star
69

Currency

[READ-ONLY] Subtree split of the Sylius Currency component for PHP E-Commerce.
PHP
8
star
70

SyliusContentBundle

[READ-ONLY] Sylius CMS specific features and integration with Symfony CMF.
PHP
7
star
71

SyliusAdminBundle

[READ-ONLY] Administration panel for Sylius eCommerce.
Twig
7
star
72

Variation

[READ-ONLY] PHP library for handling object variations.
PHP
7
star
73

DeprecatedSyliusApiBundle

[READ-ONLY] Sylius REST API bundle with OAuth Server integration.
PHP
7
star
74

Attribute

[READ-ONLY] Handling of object attributes.
PHP
7
star
75

SyliusVariableProductBundle

[READ-ONLY] Sylius product catalog extension which supports product variants and options.
PHP
7
star
76

SyliusUserBundle

[READ-ONLY] Symfony user bundle with multiple users and OAuth support.
PHP
7
star
77

SyliusCurrencyBundle

[READ-ONLY] Currencies and exchange rates management for Symfony2 e-commerce apps.
PHP
7
star
78

Customizations

Sylius application with customizations from Customization guide implemented
PHP
6
star
79

SyliusRector

PHP
6
star
80

Pricing

[READ-ONLY] Pricing component for PHP e-commerce applications.
PHP
6
star
81

Metadata

[READ-ONLY] Generic purpose metadata component for PHP.
PHP
6
star
82

SyliusVariationBundle

[READ-ONLY] Managing options and variations of PHP business entities.
PHP
6
star
83

SyliusLocaleBundle

[READ-ONLY] Locales management for Symfony2.
PHP
6
star
84

SyliusReportBundle

[READ-ONLY] Subtree split of Sylius reports system!
JavaScript
6
star
85

Storage

[READ-ONLY] Sylius data storage component.
PHP
6
star
86

Addressing

[READ-ONLY] Addresses, countries and zones management system for PHP.
PHP
6
star
87

hubkit

PHP
6
star
88

SyliusTranslationBundle

[READ-ONLY] Sylius i18n bundle.
PHP
6
star
89

SyliusUiBundle

[READ-ONLY] Sylius user interface components.
PHP
6
star
90

Originator

[READ-ONLY] Originator component subtree split.
PHP
5
star
91

SyliusContactBundle

[READ-ONLY] Sylius contact form and support system bundle.
PHP
5
star
92

SyliusSearchBundle

[READ-ONLY] Subtree split of Sylius search bundle.
PHP
5
star
93

Channel

[READ-ONLY] Sylius multichannel component for PHP e-commerce.
PHP
5
star
94

SyliusReviewBundle

[READ-ONLY] Reviews support for Symfony2 applications.
PHP
5
star
95

Translation

[READ-ONLY] Translation component for Sylius.
PHP
5
star
96

SyliusApiBundle

[READ-ONLY] Unified API for Sylius eCommerce.
PHP
5
star
97

PlusInformationCenter

Changelog and upgrade instructions for Sylius/Plus.
5
star
98

User

[READ-ONLY] Subtree split for the Sylius user component.
PHP
5
star
99

Archetype

[READ-ONLY] Subtree split of Sylius Archetype component.
PHP
5
star
100

Report

[READ-ONLY] Sylius reports component.
PHP
5
star