cwa/sylius-example-plugin

Example plugin for Creatis Web Art


README

Installation du projet

composer create-project sylius/plugin-skeleton VendorNameSyliusPluginNamePlugin

Changement dans le Nommage

Composer.json

Ajouter :

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

Changer :

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

Renomage de fichiers

src/AcmeSyliusExamplePlugin ▶️ src/VendorNameSyliusPluginNamePlugin

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

Changements dans les fichiers :

  • 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
      // ...
    • Migration Diretory :

      // ...
      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,
    // ...

Commandes à éxécuter :

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

Comment tester le plugin :

Environement de test intégré :

Importer les fichiers de configuration :

-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'}
//...

Démararer le serveur web :

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

Depuis un projet externe :

Méthode git :

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