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
Wordpress Stubs

Wordpress Stubs Laravel Package

php-stubs/wordpress-stubs

Stub declarations for WordPress core functions, classes, and interfaces (globals excluded), generated from johnpbloch's wordpress-core via php-stubs/generator. Helps plugin and theme developers leverage static analysis tools like PHPStan and Psalm, and improves IDE code completion and intellisense.

View on GitHub
Deep Wiki
Context7

Up-to-date WordPress function and class declaration stubs for static analysis by PHPStan

Frequently asked questions about Wordpress Stubs
What is php-stubs/wordpress-stubs used for?
php-stubs/wordpress-stubs provides declaration stubs for WordPress core functions, classes, and interfaces so tools like PHPStan, Psalm, and IDEs can understand WordPress APIs. It is intended for static analysis and code completion, not runtime execution. Globals such as $wpdb and $post are not included.
How do I install php-stubs/wordpress-stubs in a Laravel app?
Install it as a development dependency with composer require --dev php-stubs/wordpress-stubs. It requires PHP 7.4 or 8.0 and needs no changes to your application code. In Laravel projects, keep it in require-dev so production deployments do not load the stubs.
Does php-stubs/wordpress-stubs work with Laravel?
Yes. It is a dev-only Composer package that does not alter Laravel autoloading, service providers, or runtime behavior. It helps catch misuse of WordPress functions such as get_post or wp_insert_post when Laravel code integrates with WordPress APIs. The package is Laravel-version agnostic as long as your PHP version is supported.
Which WordPress version do the stubs support?
Release v7.1.2 targets WordPress 7.1.2, and stub versions are locked to WordPress core versions. Match the stub release to the WordPress version your plugin or theme targets. If you support older WordPress versions, pin an earlier stub release to avoid false positives for newer functions.
How do I configure PHPStan to use php-stubs/wordpress-stubs?
For PHPStan, install szepeviktor/phpstan-wordpress, which depends on phpstan/phpstan and this package. Follow that package's README and example configuration to include the WordPress stubs in your analysis. This is the recommended setup for Laravel projects that also maintain WordPress plugin or theme code.
How do I use php-stubs/wordpress-stubs with Psalm?
Add vendor/php-stubs/wordpress-stubs/wordpress-stubs.php to the stubs section of your psalm.xml configuration. Also make sure WordPress core is not included in projectFiles to avoid duplicate declarations. Then run Psalm as usual in local development or CI.
Are WordPress globals like $wpdb included in php-stubs/wordpress-stubs?
No. The stubs cover WordPress core functions, classes, and interfaces, but WordPress globals such as $wpdb, $post, and $wp_query are excluded. If your Laravel plugin relies on those globals, add custom stubs or refactor toward dependency injection where practical.
Will upgrading php-stubs/wordpress-stubs break my static analysis?
Possibly. Type-accuracy fixes in v7.1.2, including conditional return types for paginate_links and absint and corrections for sealed arrays, can change inferred types. Re-run PHPStan or Psalm after upgrading and review any new errors. Plan a short re-baseline rather than assuming the upgrade is silent.
Is php-stubs/wordpress-stubs actively maintained?
The project shows active maintenance with recent releases and contributions, but the maintainer has publicly asked for sponsorship to avoid abandoning WordPress ecosystem work. Monitor release cadence and issue activity before relying on it long term. Keep a fork or pinned version as a contingency for critical projects.
What are alternatives to php-stubs/wordpress-stubs for WordPress static analysis?
For PHPStan, szepeviktor/phpstan-wordpress is the common companion package and depends on these stubs rather than replacing them. Some teams include WordPress core source in analysis or generate custom stubs for globals and project-specific APIs. IDE built-in stubs can help with autocompletion but are not a full substitute for PHPStan or Psalm analysis.
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.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager