The problem: I am currently working on a custom plugin for Shopware 6 with the development template (https://github.com/shopware/development) and testing it on localhost.
The goal is to use my plugin for our online shop which runs on the production environment (https://github.com/shopware/production)
My problem is that my plugin works exactly like I want on localhost, but not anymore if I upload it to our production environment.
Example: I wrote a new API Controller that introduces a new Route, which does basically the same as the SyncController does but with a little extra logic.
* @Route("/api/v{version}/_action/my-extension/sync",
* name="api.action.my-extension.sync",
* methods={"POST"}
* )
The entry in my services.xml:
<service id="MyExtension\Api\Controller\CustomSyncController" public="true">
<argument type="service" id="Shopware\Core\Framework\Api\Sync\SyncService"/>
<argument type="service" id="serializer"/>
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
</service>
The entry in my routes.xml:
<import resource="../../Api/Controller" type="annotation" />
As I understand it, that should be sufficient to let Shopware 6 know what my Route is and I should be able to send my POST Request to this Route.
Everything works fine on localhost.
My question: What steps do I have to take to use this plugin on our production environment, because I always get this message on production:
{"errors":[{"code":"0","status":"404","title":"Not Found","detail":"No route found for \u0022POST \/api\/v3\/_action\/my-extension\/sync\u0022"}]}
What I tried to make it work:
- just ZIP the folder custom/plugins/MyExtension and upload my plugin to production.
- upload my plugin to localhost, run ./psh.phar administration:build, download the folder from localhost, ZIP this folder and upload it to production.
- upload my plugin to localhost, run ./psh.phar administration:build and ./psh.phar storefront:build, download the folder from localhost, ZIP this folder and upload it to production.
- After uploading my plugin also start the script "build-administration.sh" and "build-storefront.sh" on our production environment.
Currently I am lost, because I can´t understand what steps are necessary to get the same results in the production environment that I get on localhost.