Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Bing Ads Sdk Php Laravel Package

cpcstrategy/bing-ads-sdk-php

A PHP SDK for the Microsoft Advertising (Bing Ads) API, offering generated client classes for campaigns, ad groups, ads, keywords, reporting, and bulk operations so PHP applications can integrate with Bing Ads programmatically.

View on GitHub
Deep Wiki
Context7

Getting Started

This package is a set of PHP classes that wrap the Bing Ads SOAP API (v10 as of this release). It is not a Laravel-native package — there is no service provider, facade, or config file. You integrate it manually.

  1. Install / vendor the code – If the package is on Packagist, composer require it. Otherwise copy the class files into your project (e.g. app/Services/BingAds/) and ensure they are autoloaded. The v3.0.0 release splits every class into its own file (via classyfile), so PSR-4 autoloading is now practical.
  2. Configure credentials – Store your Bing Ads developer token, customer ID, account ID, and OAuth refresh token in config/services.php and .env. Never hard-code them in the example scripts.
  3. Look at the examples/ directory first – The release moved all runnable samples there. Open KeywordsAds.php for the simplest end-to-end flow (authenticate → get keywords → add/update). GeographicalLocations.php is useful for validating location targeting before building campaigns.
  4. First use case – Copy the relevant example into a Laravel command or job, replace the hard-coded credentials with config('services.bingads.*'), and run it in a sandbox account. Use php artisan tinker to instantiate the main client class and call a single read operation (e.g. GetCampaignsByAccountId) to confirm connectivity.

Implementation Patterns

  • Wrap the SDK in a service class – Create App\Services\BingAds\BingAdsClient that instantiates the SDK classes, injects credentials from config, and exposes methods like getCampaigns(), updateKeywords(). This keeps the procedural example code out of your controllers and jobs.
  • Use Laravel’s container for configuration – Bind the client as a singleton in a service provider so the OAuth token and SOAP headers are reused across requests. Inject it into jobs, commands, and controllers.
  • Queue bulk operations – BulkDownloadUpload.php and BudgetOpportunities.php can be slow. Wrap them in queued jobs (ShouldQueue) and store the resulting file paths or statuses in the database. Never run bulk uploads synchronously inside a web request.
  • Separate read and write flows – Use the read examples (KeywordsAds.php, NegativeKeywords.php, Targets.php) for reporting and dashboards. Use write examples (AdExtensions.php, ShoppingCampaigns.php) inside scheduled commands that sync local data to Bing Ads.
  • Copy examples as templates, not production code – The examples contain inline credentials, echo debugging, and hard-coded account IDs. Extract the API calls, then replace logging with Laravel’s Log facade and error handling with exceptions.
  • Version your API payloads – Since this release targets API v10, pin the SDK version in composer.json and keep a changelog of field changes (e.g. new ad extension types) so you can update your service layer deliberately.

Gotchas and Tips

  • Breaking change: class file layout – v3.0.0 moves each class into its own file. Any code that relied on a single monolithic include or on the old file paths will break. Update require statements or ensure your autoloader maps the new structure. Run composer dump-autoload after upgrading.
  • Examples moved out of the root – If you previously copied example code from the package root, those files are now under examples/. Check your git diff or deployment scripts for stale copies.
  • API v10 is old – This SDK targets Bing Ads API v10 (circa 2015). Microsoft has since deprecated v10 and moved to newer versions (v11, v12, v13). Expect missing features, unsupported endpoints, and eventual shutdown. Treat this package as legacy and plan a migration path.
  • SOAP debugging is painful – Enable SOAP request/response logging in the SDK (often via a trace option or a custom logger). Log the raw XML to a dedicated channel. Most failures are authentication (expired OAuth token, wrong developer token) or malformed SOAP headers, not business logic.
  • Authentication requires OAuth – The examples may use legacy credentials or a refresh token. Ensure your token refresh flow is implemented (e.g. a scheduled job that refreshes and stores the token). User-based authentication is required for most operations.
  • Sandbox vs production endpoints – The SDK may default to production. Explicitly set the endpoint/environment in config. Test against the Bing Ads sandbox first, especially for bulk operations.
  • No Laravel-specific extension points – There are no events, facades, or config publishing. If you need testability, wrap the SDK behind an interface and fake it in tests. Do not mock the SOAP client directly.
  • Watch for namespace collisions – The SDK classes may share names with your own models (e.g. Campaign, AdGroup). Alias them on import (use BingAds\Campaign as BingCampaign;) or keep them isolated in a service namespace.
  • Bulk file handling – BulkDownloadUpload.php writes temporary files. Ensure storage/app/bingads exists and is writable, and clean up old files with a scheduled command to avoid disk bloat.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox