Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update installation instructions #458

Merged
merged 2 commits into from
Jul 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 22 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,22 @@ The latest documentation is available [here](https://app.swaggerhub.com/apis/Syl

## Installation

1. Run `composer require sylius/shop-api-plugin:^1.0@beta`.
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 AppKernel.
1. Add SyliusShopApi to `config/bundles.php`.
```php
// app/AppKernel.php
// config/bundles.php

public function registerBundles(): array
{
return array_merge(parent::registerBundles(), [
new \Sylius\ShopApiPlugin\ShopApiPlugin(),
]);
}
return [
Sylius\ShopApiPlugin\ShopApiPlugin::class => ['all' => true],
];
```
2. Add `- { path: '^/shop-api', priorities: ['json'], fallback_format: json, prefer_extension: true }` to `fos_rest.format_listener.rules`
section in `app/config/config.yml` file and import config from Plugin.
section in `config/packages/fos_rest.yaml` file and import config from Plugin.
```yml
# app/config/config.yml

imports:
imports: # <-- Add this section if it does not already exist and add the lines below
# ...
- { resource: "@ShopApiPlugin/Resources/config/app/config.yml" }
- { resource: "@ShopApiPlugin/Resources/config/app/sylius_mailer.yml" }
Expand All @@ -57,21 +54,17 @@ The latest documentation is available [here](https://app.swaggerhub.com/apis/Syl
3. Adjust checkout configuration to not collide with Sylius shop API. For example
(assuming, that you are using regular Sylius security definition):
```yml
# app/config/config.yml

# ...
# config/packages/sylius_shop.yaml

sylius_shop:
checkout_resolver:
pattern: "%sylius.security.shop_regex%/checkout/.+"
```

4. Add routing to `app/config/routing.yml`
4. Add new routes file to import routes from the ShopApiPlugin
```yml
# app/config/routing.yml

# ...

# config/routes/sylius_shop_api.yaml

sylius_shop_api:
resource: "@ShopApiPlugin/Resources/config/routing.yml"
```
Expand All @@ -80,10 +73,12 @@ The latest documentation is available [here](https://app.swaggerhub.com/apis/Syl
2. Add ShopAPI regex parameter `shop_api.security.regex: "^/shop-api"`
3. Add ShopAPI firewall config:
```yml
# config/packages/security.yaml

parameters:
# ...

sylius.security.shop_regex: "^/(?!admin|api/.*|api$|shop-api)[^/]++" # shop-api has been added inside the brackets
sylius.security.shop_regex: "^/(?!admin|api/.*|api$|shop-api|media/.*)[^/]++" # shop-api has been added inside the brackets
shop_api.security.regex: "^/shop-api"

# ...
Expand All @@ -102,26 +97,18 @@ The latest documentation is available [here](https://app.swaggerhub.com/apis/Syl
1. Add the NelmioCorsBundle to the AppKernel

```php
// app/AppKernel.php
// config/bundles.php

/**
* {@inheritdoc}
*/
public function registerBundles()
{
$bundles = array(
// ...
new Nelmio\CorsBundle\NelmioCorsBundle(),
// ...
);
// ...
}
return [
Nelmio\CorsBundle\NelmioCorsBundle:class => ['all' => true],
];

```

2. Add the configuration to the `config.yml
2. Add the new configuration file

```yml
# app/config/config.yml
# config/packages/nelmio_cors.yml

# ...

Expand Down