cwa/sylius-example-plugin

Creatis Web Art 示例插件

安装: 0

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 2

类型:sylius-plugin


README

项目安装

composer create-project sylius/plugin-skeleton VendorNameSyliusPluginNamePlugin

命名更改

composer.json

添加

{
    "name": "vendor-name/sylius-plugin-name-plugin",
    "description": "Description of plugin",
    "version": "VERSION",
// ...

更改

// ...
 "autoload": {
        "psr-4": {
            "Acme\\SyliusExamplePlugin\\": "src/",
            "Tests\\Acme\\SyliusExamplePlugin\\": "tests/"
        }
    },
// ...
🔽
// ...
 "autoload": {
        "psr-4": {
            "VendorName\\SyliusPluginNamePlugin\\": "src/",
            "Tests\\VendorName\\SyliusPluginNamePlugin\\": "tests/"
        }
    },
// ...

文件重命名

src/AcmeSyliusExamplePlugin ▶️ src/VendorNameSyliusPluginNamePlugin

src/DependencyInjection/AcmeSyliusExampleExtension ▶️ src/DependencyInjection/VendorNameSyliusPluginNameExtention

文件更改

  • src/DependencyInjection/Configuration.php

    • namespace

      // ...
      namespace Acme\SyliusExamplePlugin;
      // ...
      🔽
      // ...
      namespace VendorName\SyliusPluginNamePlugin;
      // ...
    • treeBuilder name

      // ...
      public function getConfigTreeBuilder(): TreeBuilder
          {
              $treeBuilder = new TreeBuilder('iron_man_sylius_product_on_demand_plugin');
      // ...
      🔽
      // ...
      public function getConfigTreeBuilder(): TreeBuilder
          {
              $treeBuilder = new TreeBuilder('vendor_name_sylius_plugin_name_plugin');
      // ...
  • src/DependencyInjection/VendorNameSyliusPluginNameExtension.php

    • namespace

      // ...
      namespace Acme\SyliusExamplePlugin;
      // ...
      🔽
      // ...
      namespace VendorName\SyliusPluginNamePlugin;
      // ...
    • classname

      // ...
      final class AcmeSyliusExampleExtension extends AbstractResourceExtension implements PrependExtensionInterface
      // ...
      🔽
      // ...
      final class VendorNameSyliusPluginNameExtension extends AbstractResourceExtension implements PrependExtensionInterface
      // ...
    • 迁移目录

      // ...
      protected function getMigrationsDirectory(): string
      {
          return '@AcmeSyliusExamplePlugin/migrations';
      }
      // ...
      🔽
      // ...
      protected function getMigrationsDirectory(): string
      {
          return '@VendorNameSyliusPluginNamePlugin/migrations';
      }
      // ...
  • src/VendorNameSyliusPluginNamePlugin.php

    • namespace

      // ...
      namespace Acme\SyliusExamplePlugin;
      // ...
      🔽
      // ...
      namespace VendorName\SyliusPluginNamePlugin;
      // ...
    • classname

      // ...
      final class AcmeSyliusExamplePlugin extends Bundle
      
      // ...
      🔽
      // ...
      final class VendorNameSyliusPluginNamePlugin extends Bundle
      
      // ...
  • tests/Application/config/bundles.php

    // ...
        Acme\SyliusExamplePlugin\AcmeSyliusExamplePlugin::class => ['all' => true],
    // ...
    🔽
    // ...
        VendorName\SyliusPluginNamePlugin\VendorNameSyliusPluginNamePlugin::class => ['all' => true],
    // ...
  • tests/Application/bin/console

    // ...
    use Tests\Acme\SyliusExamplePlugin\Application\Kernel;
    // ...
    🔽
    // ...
    namespace Tests\Acme\SyliusExamplePlugin\Application;
    // ...
  • tests/Application/Kernel.php

    // ...
    namespace Tests\VendorName\SyliusPluginNamePlugin\Application;
    // ...
    🔽
    // ...
    use Tests\VendorName\SyliusPluginNamePlugin\Application\Kernel,
    // ...

要执行的命令

composer dump-autoload
(cd tests/Application && yarn install)
(cd tests/Application && yarn build)
(cd tests/Application && APP_ENV=test bin/console assets:install public)

如何测试插件

集成测试环境

导入配置文件

-Tests/Application/config/routes.yaml

//...
pluginName_example:
    resource: "@VendorNameSyliusPluginNamePlugin/src/Resources/config/app/routing.yaml"
//...

-Tests/Application/config/services.yaml

//...
imports:
    - { resource : '@VendorNameSyliusPluginNamePlugin/src/Resources/config/app/services.yaml'}
//...

启动网络服务器

(cd tests/Application && php symfony serve:start)

从外部项目

git 方法

//...
 "repositories": {
        "VendorNameSyliusPluginNamePlugin": {
            "type": "git",
            "url": "https://github.com/arhulCWA/tarteaufraise.git"
        }
    },
//...
    "require": {
//...
        "vendor-name/sylius-plugin-name-plugin" : "dev-main"
    },
//...