phpnomad / wordpress-integration
Requires
- ext-json: *
- phpnomad/asset: ^1.0
- phpnomad/auth: ^1.0
- phpnomad/cache: ^1.0
- phpnomad/console: ^1.0
- phpnomad/datastore: ^2.0
- phpnomad/db: ^2.0
- phpnomad/email: ^1.0
- phpnomad/event: ^1.0
- phpnomad/fetch: ^1.0
- phpnomad/framework: ^2.0 || ^3.0
- phpnomad/http: ^1.1
- phpnomad/loader: ^1.0 || ^2.0
- phpnomad/privacy: ^1.0
- phpnomad/rest: ^2.0
- phpnomad/tasks: ^2.1
- phpnomad/template: ^1.0
- phpnomad/translate: ^2.0
- phpnomad/utils: ^1.0
- woocommerce/action-scheduler: ^3.9
Requires (Dev)
- phpnomad/tests: ^0.3.0
- dev-main
- 4.0.1
- 4.0.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.1.0
- 2.0.5
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.0
- dev-fix/wpdb-last-error-surfacing
- dev-issue/25
- dev-issue/18
- dev-malay/fix/incompativle-fetchstrategy-interface
- dev-fixed-namespace
- dev-fix-http-namespace-errors
- dev-task/SIREN-841-Fix-package-dependency-issue
- dev-feature/packagist-migration
- dev-feature/lifterlms-integration
- dev-feature/manual-conversion-creation
This package is auto-updated.
Last update: 2026-04-16 04:30:08 UTC
README
Integrates WordPress with PHPNomad's strategy interfaces. This package maps core PHPNomad abstractions (events, cache, database, REST, tasks, auth, email, HTTP, console, templates, translation) onto WordPress core APIs so application code written against PHPNomad interfaces runs inside a plugin or theme without touching WordPress functions directly.
Installation
composer require phpnomad/wordpress-integration
Composer will pull the PHPNomad packages this integration depends on as transitive installs, along with Action Scheduler for background task dispatch.
What This Provides
WordPressInitializerwires every strategy below into the DI container, gates loading on WordPress 6.3.0 or higher, and binds WordPress actions likewp_login,wp_logout,user_register,deleted_user,set_current_user,parse_request, andwpto PHPNomad's auth, datastore, and framework events.- Event bridging through
EventStrategy(broadcasts asdo_action('phpnomad/' . $eventId)and attaches throughadd_action) andActionBindingStrategyfor mapping arbitrary WordPress actions onto PHPNomad event classes. - Cache backed by the WordPress object cache:
ObjectCacheStrategyoverwp_cache_*,CachePolicy, andWordPressObjectCacheIdempotencyStorefor task deduplication. - Database through
wpdb:QueryStrategy,QueryBuilder,ClauseBuilder, andTableCreateStrategy/TableUpdateStrategy/TableDeleteStrategy/TableExistsStrategyfor schema operations, plusDatabaseProvidersupplying prefix, charset, collation, and default TTL. - Auth and users:
UserwrapsWP_User,CurrentUserResolverStrategyreturns the current user,HashStrategyandPasswordResetStrategyhandle credentials,LoginUrlProviderexposes the login URL, andActionToCapabilityAdaptermaps PHPNomad actions onto WordPress capabilities. - REST through the WordPress REST API:
RestStrategydispatches PHPNomad controllers with middleware, validation, and interceptors, backed byRequestandResponsewrappers aroundWP_REST_RequestandWP_REST_Response. - Tasks through Action Scheduler:
WordPressTaskStrategydispatches PHPNomad tasks andWordPressTaskHandlerRegistryregisters handlers against Action Scheduler's hooks. - Transport:
FetchStrategyruns HTTP requests throughwp_remote_request, andEmailStrategysends throughwp_mail. - Console through WP-CLI:
ConsoleStrategyregisters PHPNomad commands and routes I/O throughInputandConsoleOutputStrategy. - Templates, assets, translation, mutation, and privacy:
PhpEnginerenders PHP templates,AssetStrategyresolves plugin URLs,TranslationStrategydelegates to WordPress gettext,MutationStrategywrapsapply_filters, andTrackingPermissionStrategysupplies consent information.
Requirements
- WordPress 6.3.0 or higher
- The PHPNomad packages this integration adapts (
phpnomad/auth,phpnomad/cache,phpnomad/db,phpnomad/datastore,phpnomad/event,phpnomad/rest,phpnomad/http,phpnomad/fetch,phpnomad/tasks,phpnomad/console,phpnomad/asset,phpnomad/email,phpnomad/template,phpnomad/translate,phpnomad/privacy,phpnomad/framework,phpnomad/loader), all installed automatically by Composer woocommerce/action-schedulerfor task dispatch, also installed automatically
Usage
Compose WordPressInitializer into a Bootstrapper alongside CoreInitializer and your own application initializer. A minimal plugin bootstrap looks like this:
<?php use MyApp\Application\AppInitializer; use PHPNomad\Core\Bootstrap\CoreInitializer; use PHPNomad\Di\Container\Container; use PHPNomad\Integrations\WordPress\Strategies\WordPressInitializer; use PHPNomad\Loader\Bootstrapper; add_action('plugins_loaded', function () { $container = new Container(); (new Bootstrapper( $container, new CoreInitializer(), new WordPressInitializer(), new AppInitializer() ))->load(); });
WordPressInitializer maps every PHPNomad strategy interface onto its WordPress implementation inside the container, so services in your own initializer can depend on CacheStrategy, EventStrategy, QueryStrategy, RestStrategy, and the rest without knowing they resolve to WordPress-backed classes.
Documentation
See phpnomad.com for the PHPNomad docs, including the bootstrapping guide and the interfaces this package implements. For the WordPress APIs it adapts, see the WordPress Developer Resources.
License
MIT. See LICENSE.txt.