diff --git a/guides/development/testing/unit/php-unit.md b/guides/development/testing/unit/php-unit.md index 5b437c96f5..5ae50602f2 100644 --- a/guides/development/testing/unit/php-unit.md +++ b/guides/development/testing/unit/php-unit.md @@ -179,7 +179,7 @@ class Migration1611740369ExampleDescriptionTest extends TestCase ## Mocking services -In some cases, a service should behave differently in a test run. Such a case could be where a service deletes a file or makes a critical API call. To avoid this in a test run, you can create a `/Resources/config/services_test.{xml|yml}` file that overrides your `/Resources/config/services.{xml|yml}`. But only for the test environment. +In some cases, a service should behave differently in a test run. Such a case could be where a service deletes a file or makes a critical API call. To avoid this in a test run, you can create a `/Resources/config/services_test.php` file that overrides your `/Resources/config/services.php`. But only for the test environment. In this test-only service config, you can override arguments, aliases, or parameters to change what the service container injects into services during a test run. diff --git a/guides/plugins/plugins/checkout/cart/add-cart-discounts.md b/guides/plugins/plugins/checkout/cart/add-cart-discounts.md index 1b80d6a987..dd66a049eb 100644 --- a/guides/plugins/plugins/checkout/cart/add-cart-discounts.md +++ b/guides/plugins/plugins/checkout/cart/add-cart-discounts.md @@ -118,4 +118,4 @@ Shopware comes with a called `LineItemRule`, which requires two parameters: After adding the definition to the line item, we have to calculate the current price of the discount. Therefore we can use the `PercentagePriceCalculator` of the core. The last step is to add the discount to the new cart which is provided as `Cart $toCalculate`. -That's it for the main code of our custom `CartProcessor`. Now we only have to register it in our `services.php` using the tag `shopware.cart.processor` and priority `4500`, which is used to get access to the calculation after the [product processor](https://github.com/shopware/shopware/blob/v6.3.4.1/src/Core/Checkout/DependencyInjection/cart.xml#L223-L231) handled the products. +That's it for the main code of our custom `CartProcessor`. Now we only have to register it in our `services.php` using the tag `shopware.cart.processor` and priority `4500`, which is used to get access to the calculation after the [product processor](https://github.com/shopware/shopware/blob/v6.7.14.0/src/Core/Checkout/DependencyInjection/cart.php#L505-L516) handled the products. diff --git a/guides/plugins/plugins/framework/caching/index.md b/guides/plugins/plugins/framework/caching/index.md index 72dd1d2999..62e2757561 100644 --- a/guides/plugins/plugins/framework/caching/index.md +++ b/guides/plugins/plugins/framework/caching/index.md @@ -297,16 +297,17 @@ Therefore, all events it listens to are configured over the service configuratio :::code-group -```xml [PLUGIN_ROOT/src/Core/Framework/DependencyInjection/cache.xml] - - - - - - - - - +```php [src/Core/Framework/DependencyInjection/cache.php] +$services->set(CacheInvalidationSubscriber::class) + ->args([ + service(CacheInvalidator::class), + service(Connection::class), + param('shopware.product_stream.indexing'), + ]) + ->tag('kernel.event_listener', ['event' => CategoryIndexerEvent::class, 'method' => 'invalidateCategoryRouteByCategoryIds', 'priority' => 2000]) + ->tag('kernel.event_listener', ['event' => LandingPageIndexerEvent::class, 'method' => 'invalidateIndexedLandingPages', 'priority' => 2000]) + // ... +; ``` ::: diff --git a/guides/plugins/plugins/mcp-server.md b/guides/plugins/plugins/mcp-server.md index 297a3a7593..6c793319a6 100644 --- a/guides/plugins/plugins/mcp-server.md +++ b/guides/plugins/plugins/mcp-server.md @@ -39,7 +39,7 @@ custom/plugins/SwagMyPlugin/ │ └── MyTool.php # MCP tool class └── Resources/ └── config/ - └── services.xml # Service registration + └── services.php # Service registration ``` ## Step 1: Create the tool class @@ -134,23 +134,27 @@ The attribute is **declarative only**: it populates the Admin UI coverage warnin ## Step 3: Register the service -In `src/Resources/config/services.xml`, tag the service with `shopware.mcp.tool`: - -```xml - - - - - - - - - - - +In `src/Resources/config/services.php`, tag the service with `shopware.mcp.tool`: + +```php +services(); + + $services->set(MyTool::class) + ->args([ + service('order.repository'), + service(McpContextProvider::class), + ]) + ->tag('shopware.mcp.tool'); +}; ``` Plugin tools use `shopware.mcp.tool` (not `mcp.tool`). The MCP compiler remaps this tag to `mcp.tool` at compile time and registers the tool with the MCP server builder. You do not need a `shopware.feature` flag tag; the MCP feature flag gates the server endpoint itself, and once it is enabled, all registered tools are available. @@ -180,7 +184,7 @@ bin/console debug:mcp If the tool appears here, it is available in the live HTTP endpoint. If it does not appear, check: - Plugin is installed and active -- Service has `` +- Service is tagged with `shopware.mcp.tool` - `#[McpTool]` is on the class, not on `__invoke()` ## Adding prompts @@ -234,8 +238,8 @@ Symfony bundles (not Shopware plugins) follow the same `shopware.mcp.tool` tag m ```php public function build(ContainerBuilder $container): void { - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/Resources/config')); - $loader->load('services.xml'); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/Resources/config')); + $loader->load('services.php'); } ``` diff --git a/guides/plugins/plugins/storefront/templates/add-custom-twig-function.md b/guides/plugins/plugins/storefront/templates/add-custom-twig-function.md index 6b0a0e0a0c..f51ce22bd7 100644 --- a/guides/plugins/plugins/storefront/templates/add-custom-twig-function.md +++ b/guides/plugins/plugins/storefront/templates/add-custom-twig-function.md @@ -23,7 +23,7 @@ Refer to the [Plugin Base Guide](../../plugin-base-guide.md). In the following sections, we will create and expand all necessary files for the Twig function to work. There are two such files: * PHP file with the twig functions itself and -* Services.xml +* services.php ## Creating the Twig function @@ -70,6 +70,8 @@ $services->set(SwagCreateMd5Hash::class) ->tag('twig.extension'); // Required ``` +::: + Once done, you can access this `TwigFunction` within your plugin. ## Use Twig function in template diff --git a/products/extensions/migration-assistant/concept/convert-and-mapping.md b/products/extensions/migration-assistant/concept/convert-and-mapping.md index 0d069d5946..99f86a10fc 100644 --- a/products/extensions/migration-assistant/concept/convert-and-mapping.md +++ b/products/extensions/migration-assistant/concept/convert-and-mapping.md @@ -14,11 +14,13 @@ Data gathered by `Reader` objects is transferred to `Converter` objects that put Converters are registered in the service container: -```html - - - +```php +$services->set(ProductConverter::class) + ->abstract() + ->parent(ShopwareConverter::class) + ->args([ + // ... + ]); ``` The converters have to extend the `ShopwareConverter` class and implement the `convert` method. This method will receive one data entry at a time. It will have to be returned in the right format to be usable for the `writer`. diff --git a/products/extensions/migration-assistant/concept/dataselection-and-dataset.md b/products/extensions/migration-assistant/concept/dataselection-and-dataset.md index 0c69e49bde..136658f6e0 100644 --- a/products/extensions/migration-assistant/concept/dataselection-and-dataset.md +++ b/products/extensions/migration-assistant/concept/dataselection-and-dataset.md @@ -101,10 +101,9 @@ class ProductDataSet extends DataSet The `DataSelections` are registered the following way: -```html - - - +```php +$services->set(ProductDataSelection::class) + ->tag('shopware.migration.data_selection'); ``` It is also possible to specify the same `DataSets` in multiple `DataSelections` \(this should only be done if no other options are available\). Have a look at the `ProductReviewDataSelection`: diff --git a/products/extensions/migration-assistant/concept/gateway-and-reader.md b/products/extensions/migration-assistant/concept/gateway-and-reader.md index de7c100e62..1e00517f48 100644 --- a/products/extensions/migration-assistant/concept/gateway-and-reader.md +++ b/products/extensions/migration-assistant/concept/gateway-and-reader.md @@ -12,18 +12,20 @@ Users will have to specify a gateway for the connection. The gateway defines the ## Gateway -The gateway defines how to communicate from Shopware 6 with your source system, like Shopware 5. Every profile needs to have at least one gateway. Gateways need to be defined in the corresponding service.xml using the `shopware.migration.gateway` tag: - -```html - - - - - - - - - +The gateway defines how to communicate from Shopware 6 with your source system, like Shopware 5. Every profile needs to have at least one gateway. Gateways need to be defined in the corresponding service configuration file using the `shopware.migration.gateway` tag: + +```php +$services->set(ShopwareLocalGateway::class) + ->args([ + // ... + ]) + ->tag('shopware.migration.gateway'); + +$services->set(ShopwareApiGateway::class) + ->args([ + // ... + ]) + ->tag('shopware.migration.gateway'); ``` To use the `ShopwareApiGateway`, you must download the corresponding Shopware 5 plugin [Shopware Migration Connector](https://github.com/shopware/SwagMigrationConnector) first. diff --git a/products/extensions/migration-assistant/concept/premapping.md b/products/extensions/migration-assistant/concept/premapping.md index ad42b69b8d..daf6a9e651 100644 --- a/products/extensions/migration-assistant/concept/premapping.md +++ b/products/extensions/migration-assistant/concept/premapping.md @@ -8,11 +8,12 @@ nav: The premapping will use the normal [Mapping](convert-and-mapping#mapping) to store the old identifier with the equivalent new one. All premapping readers provide the information for the mapping choices and are registered like this: -```html - - - - +```php +$services->set(SalutationReader::class) + ->args([ + // ... + ]) + ->tag('shopware.migration.pre_mapping_reader'); ``` The service will return a `PremappingStruct`, which consists of: diff --git a/products/extensions/migration-assistant/concept/profile-and-connection.md b/products/extensions/migration-assistant/concept/profile-and-connection.md index 796808f24e..9a93167210 100644 --- a/products/extensions/migration-assistant/concept/profile-and-connection.md +++ b/products/extensions/migration-assistant/concept/profile-and-connection.md @@ -12,13 +12,12 @@ Users of the plugin can create connections to different source systems. A connec ## Profile -The base of Shopware Migration Assistant is the profile, which enables you to migrate your shop system to Shopware 6. Shopware Migration Assistant comes with the default Shopware 5.5 profile and is located in the `shopware55.xml`: +The base of Shopware Migration Assistant is the profile, which enables you to migrate your shop system to Shopware 6. Shopware Migration Assistant comes with the default Shopware 5.5 profile and is located in the `shopware55.php`: -```html - - - - +```php +// Shopware 5.5 Profile +$services->set(Shopware55Profile::class) + ->tag('shopware.migration.profile'); ``` In order to identify itself, the profile has to implement getter functions like `getName()`, which returns the unique name of the profile. The profile is used together with the [Gateway](gateway-and-reader#gateway) to check and apply the right processing during a migration run. diff --git a/products/extensions/migration-assistant/concept/writer.md b/products/extensions/migration-assistant/concept/writer.md index 56e6c76ffe..b05268c65d 100644 --- a/products/extensions/migration-assistant/concept/writer.md +++ b/products/extensions/migration-assistant/concept/writer.md @@ -10,12 +10,13 @@ The `Writer` objects will get the converted data from the `swag_migration_data` When creating a writer, register it like this: -```html - - - - +```php +$services->set(ProductWriter::class) + ->parent(AbstractWriter::class) + ->args([ + // ... + ]) + ->tag('shopware.migration.writer'); ``` In most cases, you should extend `AbstractWriter`, which provides most behavior. You only need to implement the `supports` method. diff --git a/products/extensions/subscriptions/guides/separate-checkout.md b/products/extensions/subscriptions/guides/separate-checkout.md index 8e75ac5aa7..601d27bddd 100644 --- a/products/extensions/subscriptions/guides/separate-checkout.md +++ b/products/extensions/subscriptions/guides/separate-checkout.md @@ -207,20 +207,20 @@ In headless, there are two header parameters that need to be set namely `sw-subs Below is an example of the context set on a subscription cart in the Storefront: -```xml - - true - storefront - true - true - checkout - cartpage - subscription - - +```php +$routes->add('frontend.subscription.checkout.cart.page', '/subscription/checkout/cart/{subscriptionToken}') + ->controller('subscription.storefront.controller.checkout::cartPage') + ->methods(['GET']) + ->defaults([ + '_noStore' => 'true', + '_routeScope' => ['storefront'], + '_subscriptionCart' => 'true', + '_subscriptionContext' => 'true', + '_controllerName' => 'checkout', + '_controllerAction' => 'cartpage', + '_templateScopes' => 'subscription', + ]) + ->options(['seo' => false]); ``` And, here is an example of the headers set on a subscription cart using headless: @@ -239,7 +239,7 @@ curl -XPOST '/store-api/subscription/checkout/cart/line-item' / }' ``` -These context definitions can be found in `Subscription/Resources/app/config/routes/storefront.xml` or `Subscription/Resources/app/config/routes/store-api.xml`. +These context definitions can be found in `Subscription/Resources/config/routes/storefront.php` or `Subscription/Resources/config/routes/store-api.php`. ## Subscription carts in the Storefront diff --git a/products/tools/mcp-server/extending.md b/products/tools/mcp-server/extending.md index 1204498826..49b9014a84 100644 --- a/products/tools/mcp-server/extending.md +++ b/products/tools/mcp-server/extending.md @@ -52,7 +52,7 @@ Webhook response: return a JSON object, ideally following the `{"success": bool, -PHP class with `#[McpTool]` on the class, tagged `shopware.mcp.tool` in `services.xml`. +PHP class with `#[McpTool]` on the class, tagged `shopware.mcp.tool` in `services.php`. ```php #[McpTool(name: 'swag-my-plugin-orders', title: 'Order List', description: 'List recent orders.')] @@ -76,12 +76,12 @@ class OrdersTool extends McpToolResponse -Identical PHP class and `services.xml` as a plugin. Load services unconditionally in the bundle's `build()` method — the MCP feature flag gates the HTTP endpoint, not the service registration: +Identical PHP class and `services.php` as a plugin. Load services unconditionally in the bundle's `build()` method — the MCP feature flag gates the HTTP endpoint, not the service registration: ```php public function build(ContainerBuilder $container): void { - // load services.xml with shopware.mcp.tool tag + // load services.php with shopware.mcp.tool tag } ``` @@ -89,7 +89,7 @@ To register the bundle itself only when the MCP feature is active, gate the entr Bundles have no install/activate lifecycle. They are always active when registered in `config/bundles.php`. -→ [Plugin guide](../../../guides/plugins/plugins/mcp-server.md): the PHP class and services.xml patterns are identical +→ [Plugin guide](../../../guides/plugins/plugins/mcp-server.md): the PHP class and services.php patterns are identical diff --git a/products/tools/mcp-server/troubleshooting.md b/products/tools/mcp-server/troubleshooting.md index 223ade3c9e..9ea5e55b82 100644 --- a/products/tools/mcp-server/troubleshooting.md +++ b/products/tools/mcp-server/troubleshooting.md @@ -130,7 +130,7 @@ If a tool does not appear in the `debug:mcp` output, it will also be missing fro **For plugin tools:** - Confirm the plugin is installed and activated: `bin/console plugin:list` -- Confirm the service has `` in `services.xml` +- Confirm the service is tagged with `shopware.mcp.tool` in `services.php` - Confirm `#[McpTool]` is on the **class**, not on `__invoke()` - Run `bin/console cache:clear` after changes