Download the PHP package basecom/sw6-fixtures-plugin without Composer
On this page you can find all versions of the php package basecom/sw6-fixtures-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download basecom/sw6-fixtures-plugin
More information about basecom/sw6-fixtures-plugin
Files in basecom/sw6-fixtures-plugin
Package sw6-fixtures-plugin
Short Description basecom Fixtures Plugin
License proprietary
Informations about the package sw6-fixtures-plugin
Fixture Plugin
The fixture plugin is really helpful if you want to create some static demo data for your shopware instance.
Installation
Just add it to your project via composer:
Afterwards you can install the plugin, like any other Shopware Plugin using the administration or console command:
PHP & Shopware compatibility
Please use the following table to check which version can be used for your PHP and shopware version
Shopware Version | PHP Versions | Newest FixturePlugin version | Supported |
---|---|---|---|
6.6.* | v8.2, v8.3 | v3.0.* | ✅ |
6.5.* | v8.2, v8.3 | v3.0.* | ✅ |
6.5.* | v8.1 | v2.0.* | ❌ |
6.4.* | v8.1, v8.2 | v2.0.* | ❌ |
6.3.* | v8.1, v8.2 | v2.0.* | ❌ |
Create Fixtures
Basic Fixture
Create a new file in the specific folder of your project for the fixtures and extend this file from abstract class "Fixture" in the library.
Then just implement the "load()" method with fixture logic.
Priority and Dependency
You can also add an optional priority or dependency of other Fixture classes via the corresponding "dependsOn()" or "priority()" method.
Groups
If you want to run specific fixtures as a group later, implement the "groups()" method from the abstact class and return an array of strings as group names.
Register Fixtures
If you're using service autowiring, then nothing needs to be done to register your fixtures.
If you're not using autowiring, then please register your fixtures with the tag basecom.fixture
.
Running Fixtures
Run all fixtures
To run all registered fixtures, just use this command.
Run single fixture
To run a single fixture, use this command with your fixture name as parameter.
By default, if you run a single fixture it will ignore all its dependencies. If you want to run the single fixture,
including all dependencies recursively, use the --with-dependencies
option.
Run group
To run a group of fixture, run this command with group name as parameter (specified via groups() method). It´s also case-insensitive.
Best Practices
Plugin Development
When you want to add fixtures to a plugin that you build, you might not want to deliver these fixtures in a production version of your plugin. In this case, we only want to add it to the "development" or "testing" scope of our plugin.
Create a new folder for your fixtures in a folder that is not your source folder that is delivered. You could use your "tests" folder for instance.
We then use the Shopware build()
function of our main Plugin
class to add the code below.
This code will verify if our DEV dependencies from our composer dependencies are installed (just use any check like, is PHPUnit existing?...).
Once it recognizes that DEV requirements are installed, we verify that our fixtures directory also exists, and then simply load
those files with our correct namespace in our class loader.
Afterwards we also load our custom XML services for our fixtures.
With this approach, the bin/console
command of this FixturePlugin will only find fixtures, if dev-dependencies are installed in our plugin that we develop.
If only production dependencies are installed, nothing is found and therefore no fixtures are (accidentally) loaded.
Contribution
This template uses a full-featured Dockware docker image. It already comes with a pre-installed Shopware 6 instance and everything you need to start developing.
Please see the Dockware documentation.
To start developing, simply start the container:
Access the container:
Install the dependencies and make everything ready (defined in composer.json and package.json). This command needs to be executed from the host-system (not in shell)
Linting
Before committing, please run the linting and static analysis tools. This command also needs to be executed from the host machine (not in shell):
Github Actions
The Github actions pipeline is already pre-configured. It contains multiple jobs for all linting, static analysis and testing tools.
All versions of sw6-fixtures-plugin with dependencies
shopware/core Version 6.3.*|6.4.*|6.5.*
shopware/administration Version 6.3.*|6.4.*|6.5.*
shopware/storefront Version 6.3.*|6.4.*|6.5.*