VOOZH about

URL: https://deepwiki.com/auth0/wordpress/4-development

⇱ Development | auth0/wordpress | DeepWiki


Loading...
Menu

Development

This page provides guidance for developers working with or extending the Auth0 WordPress plugin codebase. It covers the development environment structure, available tooling, testing practices, and how to programmatically interact with the plugin.

For details on specific topics:

Development Environment Structure

The plugin uses a standard PHP development environment with Composer for dependency management and PSR-4 autoloading. The codebase is organized to separate production code from development tooling and tests.


Directory and File Structure

PathPurpose
src/Production source code organized under Auth0\WordPress namespace
tests/Test suites organized under Auth0\Tests namespace
vendor/Composer dependencies (gitignored, created by composer install)
build/Production build output with scoped dependencies (gitignored)
wpAuth0.phpPlugin entry point that bootstraps the plugin
composer.jsonDependency declarations and development scripts
phpunit.xml.distPHPUnit/Pest test framework configuration
phpstan.neonPHPStan static analysis configuration
psalm.xmlPsalm static analysis configuration
rector.phpRector refactoring rules configuration
.php-cs-fixer.phpPHP-CS-Fixer code style configuration
scoper.inc.phpPHP-Scoper namespace prefixing configuration

Sources: README.md56-76 composer.json61-69

Composer Scripts

The plugin provides Composer scripts for common development tasks. All scripts are defined in composer.json97-117 and can be executed using composer <script-name>.

Available Scripts

ScriptCommandPurpose
build./build.shExecute full build process including dependency scoping
pest@php vendor/bin/pest --order-by random --fail-on-risky --parallel --no-progressRun test suite with Pest
pest:coverage@php vendor/bin/pest --order-by random --fail-on-risky --coverage --parallel --no-progressRun tests with code coverage reporting
pest:debug@php vendor/bin/pest --log-events-verbose-text pest.log --display-errors --fail-on-risky --no-progressRun tests with verbose debug logging
pest:profile@php vendor/bin/pest --profileRun tests with performance profiling
phpcs@php vendor/bin/php-cs-fixer fix --dry-run --diffCheck code style without modifying files
phpcs:fix@php vendor/bin/php-cs-fixer fixAuto-fix code style violations
phpstan@php vendor/bin/phpstan analyzeRun PHPStan static analysis
psalm@php vendor/bin/psalmRun Psalm static analysis
psalm:fix@php vendor/bin/psalter --issues=allAuto-fix issues detected by Psalm
rector@php vendor/bin/rector process src --dry-runCheck for available refactorings
rector:fix@php vendor/bin/rector process srcApply automated refactorings
testMultipleRun complete test suite: Pest, PHPStan, Psalm, Rector, PHP-CS-Fixer

Composite Test Command

The composer test command executes all quality assurance tools in sequence:


This runs:

  1. @pest - Test suite execution
  2. @phpstan - PHPStan static analysis
  3. @psalm - Psalm static analysis
  4. @rector - Rector refactoring checks
  5. @phpcs - PHP-CS-Fixer code style checks

Sources: composer.json97-117

Development Dependencies

The plugin requires several development dependencies for testing and code quality assurance. These are declared in composer.json42-59


Key Development Dependencies

PackageVersionPurpose
pestphp/pest^2Modern PHP testing framework (PHPUnit wrapper)
mockery/mockery^1Object mocking for tests
phpstan/phpstan^1Static analysis for type checking
vimeo/psalm^5Alternative static analysis tool
friendsofphp/php-cs-fixer^3Automated code style fixing
rector/rector0.17.0Automated refactoring tool
humbug/php-scoper^0.18Namespace prefixing for distribution
nyholm/psr7^1PSR-7 HTTP message implementation
symfony/cache^6PSR-6 cache implementation

Sources: composer.json42-59

Plugin Access Pattern

The plugin provides the wpAuth0() helper function for accessing the plugin instance and the underlying Auth0-PHP SDK. This is the recommended pattern for custom development.

Plugin Singleton Access


Important Warning

The plugin's internal APIs are not stable and will change without notice. Do not extend or subclass the plugin's classes directly. Instead, use the wpAuth0() helper to access the Auth0-PHP SDK for custom development.

Usage Example

From README.md176-182:


The Plugin class exposes the following public methods:

MethodReturn TypePurpose
getSdk()Auth0\SDK\Auth0Returns configured Auth0-PHP SDK instance
getConfiguration()Auth0\SDK\Configuration\SdkConfigurationReturns SDK configuration object
run()selfInitializes plugin hooks (called once during bootstrap)

Sources: README.md14-15 README.md169-184

Development Workflow

A typical development workflow involves making code changes, running tests and quality checks, and creating production builds.


Recommended Workflow Steps

  1. Install Dependencies: Run composer install to fetch all development dependencies
  2. Make Changes: Edit source code in src/ directory
  3. Run Tests: Execute composer pest to verify functionality
  4. Check Types: Run composer phpstan and composer psalm for type safety
  5. Check Style: Run composer phpcs to verify code style compliance
  6. Auto-fix: Use composer phpcs:fix and composer psalm:fix to automatically resolve issues
  7. Full Validation: Run composer test to execute all quality checks
  8. Build: Execute composer build (via ./build.sh) to create production-ready package

Development vs Production Autoloading

The plugin's bootstrap file wpAuth0.php checks for different autoloader files depending on the environment:

  • Production: Loads scoper-autoload.php which includes scoped dependencies under Auth0\WordPress\Vendor namespace
  • Development: Falls back to autoload.php for unscoped dependencies during development

This allows development to proceed with standard Composer dependencies while production builds use isolated, prefixed namespaces to prevent conflicts with other plugins.

Sources: composer.json97-117 README.md203-216

Test Configuration

The test suite uses PHPUnit/Pest configuration defined in phpunit.xml.dist1-27

Test Configuration Settings

SettingValuePurpose
Test Suitetests/Unit/Location of unit tests
Coverage Outputcoverage/clover.xml, coverage/cobertura.xmlCode coverage report formats
Source Includesrc/Files to include in coverage analysis
Source Excludesrc/Events/, src/Exceptions/Directories excluded from coverage
EnvironmentCACHE_DRIVER=arrayTest environment configuration

Coverage Reports

When running composer pest:coverage, the test suite generates two coverage report formats:

  • Clover XML: coverage/clover.xml - Machine-readable coverage data
  • Cobertura XML: coverage/cobertura.xml - Compatible with CI/CD tools

Sources: phpunit.xml.dist1-27

Code Organization

The plugin's source code follows PSR-4 autoloading standards with a namespace structure that maps to the directory layout.


PSR-4 Autoload Configuration

From composer.json61-69:

NamespaceDirectoryEnvironment
Auth0\WordPress\src/Production
Auth0\Tests\tests/Development

This configuration allows classes to be referenced by their fully-qualified namespace, with the autoloader automatically mapping to the correct file path.

Sources: composer.json61-69