Skip to content

hubertinio/SyliusExamplePlugin

Repository files navigation

Better Plugin Skeleton

Skeleton for starting Sylius plugins in a few minutes with docker.

Source repo

What was updated?

  • docker has the same versions as github actions (php 8.1, mysql 8.0, node 18.x)
  • paths are correct and works without hasitate
  • services.php for services.yaml
  • installation updated and closed in Makefile commands

Init

git clone [email protected]:hubertinio/SyliusExamplePlugin.git SyliusUnicornPlugin

What to rename?

Let's assume that the new plugin is Vendor\SyliusUnicornPlugin

  • update name in the composer.json into vendor\sylius-unicorn-plugin
  • find and replace Hubertinio\\SyliusExamplePlugin into Vendor\\SyliusUnicornPlugin
  • find and replace Hubertinio\SyliusExamplePlugin into Vendor\SyliusUnicornPlugin
  • find and replace with case-sensitive HubertinioSyliusExamplePlugin into VendorSyliusUnicornPlugin
  • find and replace with case-sensitive hubertiniosyliusexampleplugin into vendorsyliusunicornplugin
  • find and replace hubertinio_sylius_example into vendor_sylius_unicorn
  • refactor class and file name src/HubertinioSyliusExamplePlugin.php into VendorSyliusUnicornPlugin.php
  • refactor class and file name src/DependencyInjection/HubertinioSyliusExampleExtension.php into src/DependencyInjection/VendorSyliusUnicornExtension.php

Quickstart Installation

Docker

  1. Execute make build-containers and make start-containers

  2. Initialize everything make install

  3. See your localhost

Traditional way

Don't tested yet.

Composer install

For existing projects.

Set private repository.

    "repositories": [
        {
            "type": "vcs",
            "url": "[email protected]:vendor/SyliusUnicornPlugin.git"
        }
    ],

Install.

composer require vendor/sylius-unicorn-plugin:1.12.x-dev

Register plugin

Insert into tests/Application/config/bundles.php array that line:

Vendor\SyliusUnicornPlugin\VendorSyliusUnicornPlugin::class => ['all' => true],

How to add routing?

Insert into tests/Application/config/routes.yaml this content:

vendor_sylius_unicorn_plugin:
    resource: "@VendorSyliusUnicornPlugin/config/routing.yml"

Documentation

For a comprehensive guide on Sylius Plugins development please go to Sylius documentation, there you will find the Plugin Development Guide, that is full of examples.

Usage

Running plugin tests

  • PHPUnit

    vendor/bin/phpunit
  • PHPSpec

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

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

    1. Install Symfony CLI command.

    2. Start Headless Chrome:

    google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1
    1. Install SSL certificates (only once needed) and run test application's webserver on 127.0.0.1:8080:
    symfony server:ca:install
    APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon
    1. Run Behat:
    vendor/bin/behat --strict --tags="@javascript"
  • Static Analysis

    • Psalm

      vendor/bin/psalm
    • PHPStan

      vendor/bin/phpstan analyse -c phpstan.neon -l max src/  
  • Coding Standard

    vendor/bin/ecs check