{"id":26984717,"url":"https://github.com/vienthuong/shopware-php-sdk","last_synced_at":"2025-05-15T14:04:43.931Z","repository":{"id":37091565,"uuid":"378744734","full_name":"vienthuong/shopware-php-sdk","owner":"vienthuong","description":"A PHP SDK for Shopware 6 Admin API","archived":false,"fork":false,"pushed_at":"2025-03-20T08:59:06.000Z","size":660,"stargazers_count":115,"open_issues_count":7,"forks_count":48,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-11T22:38:08.554Z","etag":null,"topics":["php-sdk","shopware","shopware-6","shopware-6-sdk","shopware-php-sdk","shopware-sdk"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vienthuong.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-20T21:39:32.000Z","updated_at":"2025-03-20T08:59:12.000Z","dependencies_parsed_at":"2023-12-25T12:28:03.865Z","dependency_job_id":"83ce5cec-2998-4904-93bf-26247596ad3d","html_url":"https://github.com/vienthuong/shopware-php-sdk","commit_stats":{"total_commits":45,"total_committers":17,"mean_commits":"2.6470588235294117","dds":0.5777777777777777,"last_synced_commit":"772876c243b64003094a7bd648d5e92ae446089d"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vienthuong%2Fshopware-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vienthuong%2Fshopware-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vienthuong%2Fshopware-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vienthuong%2Fshopware-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vienthuong","download_url":"https://codeload.github.com/vienthuong/shopware-php-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254119438,"owners_count":22017947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php-sdk","shopware","shopware-6","shopware-6-sdk","shopware-php-sdk","shopware-sdk"],"created_at":"2025-04-03T17:48:51.757Z","updated_at":"2025-05-15T14:04:43.911Z","avatar_url":"https://github.com/vienthuong.png","language":"PHP","readme":"# Shopware 6 PHP SDK\n\n![php](https://img.shields.io/badge/PHP-777BB4?style=for-the-badge\u0026logo=php\u0026logoColor=white) \n\n[![GitHub Release](https://img.shields.io/github/v/release/vienthuong/shopware-php-sdk.svg?style=flat)]()\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n\nShopware PHP SDK is a simple SDK implementation of Shopware 6 APIs. It helps to access the API in an object-oriented way.\n\nIf you're familiar with Shopware 6 DAL syntax and how to retrieve it you might see this example is predictable and straightforward\n\n![image](https://i.imgur.com/NyXy2db.png)\n\nOr sending notification from external server\n![image](https://i.imgur.com/26LdTab.png)\n\n| SDK version | SW schema |\n|-------------|:---------:|\n| 2.x         |    \u003e=6.5    |\n| 1.x         |    6.4    |\n\nYou can use 1.x to connect to a sw 6.5 but for up-to-date schema and new 6.5 features, you should use 2.x version instead.\n\n## Installation\nInstall with Composer\n```shell\ncomposer require vin-sw/shopware-sdk\n```\n\n# The SDK main features:\n\n- Admin API\n  - CRUD API \n  - Sync Api\n  - User Config API\n  - Notification API\n  - Admin Search API\n  - Other services  \n  - ... (TODO)\n  \n- Webhook helper\n  - Webhook registration\n  - Webhook authentication  \n  - Webhook receiver\n\n- If you're using Laravel 8, consider check this out [Laravel Shopware SDK Adapter](https://github.com/Shape-and-Shift/shopware-laravel-sdk)\n\n## Usage\n\nMore in the examples folder, for integrating the sdk in an App, have a look at this [repository](https://github.com/vienthuong/AppExample)\n\n## Admin Authentication\n- Supported 3 grant types, you can create one of these 3 grant type for authentication:\n\nUsing Password grant type\n```php\n$grantType = new PasswordGrantType($username, $password);\n```\n\nUsing Client credential grant type\n\n```php\n$grantType = new ClientCredentialsGrantType($clientId, $clientSecret);\n```\n\nUsing Refresh token grant type\n\n```php\n$grantType = new RefreshTokenGrantType($refreshToken);\n```\n\nOr dynamically via\n\n```php\n$grantType = GrantType::createFromConfig($config);\n```\n\nCheck the [authentication](examples/authentication.php) example for the reference.\n\nAfter having a GrantType object, you can fetch the admin's access token using the AdminAuthenticator\n\n```php\n$adminClient = new AdminAuthenticator($grantType, $shopUrl);\n$accessToken = $adminClient-\u003efetchAccessToken();\n$context = new Context($shopUrl, $accessToken);\n```\n\n**Notice:** You might want to store the access token object into the database so you can create the object without request for another access token for every Admin API request.\n\n## Working with Criteria and Repositories\n\nIt's pretty identical to what you expected when working with Shopware's core or repositories in the SW administration.\n\nThis is an example to retrieve a product that have free shipping\n```php\n// Create the repository for the entity\n$productRepository = RepositoryFactory::create(ProductDefinition::ENTITY_NAME);\n\n// Create the criteria\n$criteria = new Criteria();\n$criteria-\u003eaddFilter(new EqualsFilter('shippingFree', true));\n\n// Using this criteria and the context object that you create from authentication step, you can retrieving the result\n$products = $productRepository-\u003esearch($criteria, $context);\n```\n\nEach shopware's entity is mapped into Entity and Collection Classes which can be found in [Data/Entity](/src/Data/Entity) so you can easily access their properties when retrieving data from Admin API.\n\nSupport methods `get`, `search`, `searchIds`, `create`, `update`, `delete`, `syncDeleted`, `createVersion`, `mergeVersion`, `deleteVersion`, `clone`, `schema`.\nEach method requires a [Context](src/Data/Context.php) object\n\nCheck [examples/entity-repository.php](/examples/entity-repository.php) for some useful references.\n\n## Working with App\n\n### AppRegistration examples:\nThe example took from a Laravel route action, but it can be the same in other frameworks\n\n```php\npublic function register(ShopRepository $repository): RegistrationResponse\n{\n    $authenticator = new WebhookAuthenticator();\n\n    $app = new App(config('sas_app.app_name'), config('sas_app.app_secret'));\n\n    $response = $authenticator-\u003eregister($app);\n\n    // Save the response the database...\n    $repository-\u003ecreateShop($response-\u003egetShop());\n\n    $confirmationUrl = route('sas.app.auth.confirmation');\n\n    return new RegistrationResponse($response, $confirmationUrl);\n}\n\npublic function confirm(Request $request, ShopRepository $shopRepository): Response\n{\n    $shopId = $request-\u003erequest-\u003eget('shopId');\n\n    $shopSecret = $shopRepository-\u003egetSecretByShopId($shopId);\n\n    if (!WebhookAuthenticator::authenticatePostRequest($shopSecret)) {\n        return new Response(null, 401);\n    }\n\n    $shopRepository-\u003eupdateAccessKeysForShop(\n        $shopId,\n        $request-\u003erequest-\u003eget('apiKey'),\n        $request-\u003erequest-\u003eget('secretKey')\n    );\n\n    return new Response();\n}\n```\n\n### Action Button Response examples:\nWhen receive a POST request from an action button, you can return one of these ActionResponse (PSR-7 Response) classes ported from Shopware's core\n\n```php\nnamespace Vin\\ShopwareSdk\\Data\\Response;\n/**\n* @see Shopware\\Core\\Framework\\App\\ActionButton\n */\nnew EmptyResponse();\nnew ReloadDataResponse($shopSecret);\nnew OpenNewTabResponse($shopSecret, 'http://shopware.test');\nnew NotificationResponse($shopSecret, 'Success!', NotificationResponse::SUCCESS);\nnew NotificationResponse($shopSecret, 'Error!', NotificationResponse::ERROR);\nnew OpenModalResponse($shopSecret, $iframeUrl, OpenModalResponse::LARGE_SIZE, true);\n```\n\n## Working with Admin API Services\n- Current supported services: \n  - [InfoService](/src/Service/InfoService.php)\n  - [MediaService](/src/Service/MediaService.php)\n  - [UserService](/src/Service/UserService.php)\n  - [StateMachineService](/src/Service/StateMachineService.php)\n  - [SyncService](/src/Service/SyncService.php)\n  - [NotificationService](/src/Service/NotificationService.php)\n  - [UserConfigService](/src/Service/UserConfigService.php)\n  - [AdminSearchService](/src/Service/AdminSearchService.php)\n  - For other services that does not have a concrete class, use: [AdminActionService](/src/Service/AdminActionService.php)   \n  \nAn ApiService requires a [Context](src/Data/Context.php) object as its first argument. \nCheck [examples/sync-service.php](/examples/sync-service.php) or [examples/info-service.php](/examples/info-service.php) for some references.\n\n## Change log\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Working with Webhook\n- Check the integration on our [AppExample](https://github.com/vienthuong/AppExample)\n\n## Contribution\nFeels free to create an issue on Github issues page or contact me directly at levienthuong@gmail.com\n\n## Security\nIf you discover any security related issues, please email levienthuong@gmail.com instead of using the issue tracker.\n\n### Requirements\n- ext-curl\n- PHP \u003e=7.4\n- SW \u003e= 6.4\n\nThis SDK is mainly dedicated to Shopware 6.4 and onwards, earlier SW application may still be usable without test\n\n## Credits\n\n- [vienthuong][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/vin-sw/shopware-sdk.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[link-packagist]: https://packagist.org/packages/vin-sw/shopware-sdk\n[link-downloads]: https://packagist.org/packages/vin-sw/shopware-sdk\n[link-author]: https://github.com/vienthuong\n[link-contributors]: ../../contributors\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvienthuong%2Fshopware-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvienthuong%2Fshopware-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvienthuong%2Fshopware-php-sdk/lists"}