Skip to content

FriendsOfSylius Plugin for Sylius to update exchange rates using the Swap PHP library

Notifications You must be signed in to change notification settings

FriendsOfSylius/SyliusExchangeRatesPlugin

Repository files navigation

FOSSyliusExchangeRatePlugin

Installation

  1. Require and install the plugin
  • Run composer require friendsofsylius/sylius-exchange-rate-plugin --dev
  1. Add plugin dependencies to your AppKernel.php file:
public function registerBundles()
{
    return array_merge(parent::registerBundles(), [
        ...
        new \Florianv\SwapBundle\FlorianvSwapBundle(),
        new \FriendsOfSylius\SyliusExchangeRatePlugin\FOSSyliusExchangeRatePlugin(),
    ]);
}

Configuration

Application configuration:

sylius_grid:
    templates:
        action:
            import_exchange_rates: "@FOSSyliusExchangeRatePlugin/importAction.html.twig"
    grids:
        sylius_admin_exchange_rate:
            actions:
                main:
                    import:
                        type: import_exchange_rates

florianv_swap:
    providers:
        # choose the provider you want, for example google finance
        # for the full list of options see:
        # https://github.com/florianv/symfony-swap/blob/master/Resources/doc/index.md#builtin-providers
        google_finance: ~

fos_sylius_exchange_rate: ~

Routing configuration (only necessary if web_ui is set to true):

sylius_exchange_rate:
    resource: "@FOSSyliusExchangeRatePlugin/Resources/config/routing.yml"

Usage

CLI commands

  • Import configured exchange rates

    $ bin/console sylius:import-exchange-rates

Running plugin tests

  • Test application install

    $ composer install
    $ (cd tests/Application && yarn install)
    $ (cd tests/Application && yarn run gulp)
    $ (cd tests/Application && bin/console assets:install web -e test)
    
    $ (cd tests/Application && bin/console doctrine:database:create -e test)
    $ (cd tests/Application && bin/console doctrine:schema:create -e test)
    
  • PHPUnit

    $ bin/phpunit
  • PHPSpec

    $ bin/phpspec run
  • Behat (non-JS scenarios)

    $ bin/behat features --tags="~@javascript"
  • Behat (JS scenarios)

    1. Download Chromedriver

    2. Run Selenium server with previously downloaded Chromedriver:

      $ bin/selenium-server-standalone -Dwebdriver.chrome.driver=chromedriver
    3. Run test application's webserver on localhost:8080:

      $ (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web -e test)
    4. Run Behat:

      $ bin/behat features --tags="@javascript"

Opening Sylius with your plugin

  • Using test environment:

    $ (cd tests/Application && bin/console sylius:fixtures:load -e test)
    $ (cd tests/Application && bin/console server:run -d web -e test)
  • Using dev environment:

    $ (cd tests/Application && bin/console sylius:fixtures:load -e dev)
    $ (cd tests/Application && bin/console server:run -d web -e dev)

About

FriendsOfSylius Plugin for Sylius to update exchange rates using the Swap PHP library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published