jeffersongoncalves/laravel-wordpress
Laravel WordPress integrates Laravel apps with WordPress, offering a simple way to connect to the WordPress REST API, fetch posts and content, and sync data between your Laravel application and a WordPress site without extra boilerplate.
composer require <vendor>/<package>
php artisan vendor:publish --provider="...\WordpressServiceProvider"
https://blog.example.com), credentials (WordPress username + Application Password), and REST namespace (default wp/v2). Keep these in .env and reference them from config/wordpress.php — never hardcode the password.Wordpress facade (entry point for every resource group), then the config file, then the Boost guidelines/skill shipped with the package — those encode the resource/method map faster than reading source.A good second step is a single write operation in a staging WP install: create a draft post. Drafts are cheap to clean up and prove the auth user has edit_posts.
Wrap the facade, don't scatter it. Create a thin WordpressContent / WordpressRepository service that injects the client and exposes only the operations your app needs (latestPosts(), publishDraft()). The facade is convenient in tinker and artisan commands, but constructor-injected services keep controllers testable and give you one place to add caching and retries.
Cache every read. Posts, pages, categories, and tags change rarely relative to how often you render them. Wrap list/get calls in Cache::remember() keyed by resource + id/slug + query hash, and invalidate explicitly after your own create/update/delete calls. Do not rely on WP to tell you when a human edited content in wp-admin — add a scheduled refresh or a short TTL for anything editorial.
Featured-image pipeline. Media upload takes a raw body plus Content-Disposition (which carries the filename), so build one helper:
$media = $wordpress->media()->upload($contents, $filename, $mimeType);
// then pass $media['id'] as featured_media when creating/updating the post
Keep this in a single attachFeaturedImage() method; the two-step dance (upload → set ID) is the most error-prone sequence in the package.
Content sync jobs. For import/export between WordPress and Eloquent, put the work in queued jobs or an artisan command, not a web request. Store the WP id on your local model as a unique key, and make the job idempotent (updateOrCreate on that key) so retries don't duplicate.
Pagination and bulk operations. Iterate page-by-page rather than requesting everything at once, and drive bulk edits from a queued job with a small delay so you don't trip WP host rate limits or PHP execution limits.
Testing. The package is built on Laravel's HTTP client, so Http::fake() should intercept calls — assert on the outgoing URL, method, and body rather than on the package's return shape, which keeps tests stable across patch releases. For higher-level tests, bind a fake implementation of your own wrapper service into the container.
Comments and users are best treated as admin-panel concerns: build moderation screens on top of the full CRUD rather than exposing them publicly. /users/me is the natural "is my credential still valid?" health check — call it from a scheduled command and alert on 401.
http://, expect silent 401s. Also confirm the feature isn't disabled by a security plugin or host — many managed WP hosts do.delete is not delete. The default delete trashes; force-delete is permanent and unrecoverable. Never wire force-delete to a public route, and log it when you do use it.Content-Type vs the actual file, a missing filename in Content-Disposition, an unsupported MIME type (WP has an allowlist), or the WordPress host's upload_max_filesize — not your Laravel app's. Check the WP-side limits first.content field is filtered/rendered by default; raw content needs context=edit, which in turn needs auth and the right capability. If you're round-tripping content, be explicit about which you're reading and writing, or you'll mangle shortcodes and block markup.rtrim($url, '/')) rather than debugging per-call.curl before blaming the client.code and message in the JSON body that are far more informative than the HTTP status alone. Reproduce with curl -u user:app_password to isolate package issues from WordPress config issues.Wordpress facade can be swapped for a fake via the container for tests; and the shipped Boost guidelines/skill are the fastest way to teach an AI assistant (or a new teammate) the package's conventions rather than having them infer them from source.How can I help you explore Laravel packages today?