https://github.com/woocommerce/woocommerce-example-package
Example package for a WooCommerce feature plugin that can also be included in core.
https://github.com/woocommerce/woocommerce-example-package
Last synced: 3 months ago
JSON representation
Example package for a WooCommerce feature plugin that can also be included in core.
- Host: GitHub
- URL: https://github.com/woocommerce/woocommerce-example-package
- Owner: woocommerce
- Created: 2019-06-25T11:59:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-25T13:22:28.000Z (over 6 years ago)
- Last Synced: 2025-03-22T05:33:50.942Z (10 months ago)
- Language: Shell
- Homepage: https://packagist.org/packages/woocommerce/woocommerce-example-package
- Size: 2.34 MB
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WooCommerce Example Package
This is an example feature plugin package for WooCommerce. It is setup so that it can be installed standalone as a WordPress plugin, or included into another project/WooCommerce core as a Composer Package.
## Installing Composer
You need Composer to use the packages. If you don't have it installed, go and check how to [install Composer](https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment) and then continue here.
## Installing packages
Once you have defined your package requirements, run
```
composer install
```
and that will install the required Composer packages.
The example package has some package requirements defined:
- `"automattic/jetpack-autoloader"` - Handles autoloading and prevents version conflicts between packages.
- `"composer/installers"` - Allows the plugin to be installed via composer and moved to the correct install directory.
- `"phpunit/phpunit"` - Runs unit tests.
- `"woocommerce/woocommerce-sniffs"` - Checks for coding standards violations.
## Main directories and files
- `woocommerce-example-package.php` - The main plugin file. ONLY used when using this package as a plugin!
- `src/` - PSR-4 named classes under your namespace are placed here. Classes will be autoloaded.
- `src/Package.php` - The package class requires 3 static methods;
- `init` - Init your package. If it needs to hook into WordPress, do so here.
- `get_version` - Return the version of your package here. This will be used by WooCommerce in the system status report.
- `get_path` - Return the package main directory. This will be used by WooCommerce in the system status report.
- `tests/` - Unit tests ran using `phpunit`.
## Adding and running unit tests
Tests should be added in the `tests/Tests` directory.
You can run the tests by running the command
```
./vendor/bin/phpunit
```
from the plugin directory.