Download the PHP package wppunk/wpplugin without Composer
On this page you can find all versions of the php package wppunk/wpplugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package wpplugin
WP Plugin
Get Started
One-line install:
Or you can copy the archive or clone via Git and then run:
Requirements
Make sure all dependencies have been installed before moving on:
- WordPress
- PHP >= 7.2.5 (You can easily downgrade it)
- DOM extension
- CURL extension
- Composer
- Node.js >= 14.8
- npm
- ChromeDriver (for acceptance tests)
Structure
Autoload
We use PSR-4 and composer autoload for PSR-4. You can find it in composer.json
in directive autoload
.
Coding Standards
To check all coding standards:
PHP Coding Standard (PHPCS)
We use a custom coding standard based on WordPress Coding Standard. We disabled rules for the naming of WordPress files for using PSR-4 autoload. Also, we have a feature, which can allow testing your code using different PHP environments.
Custom PHPCS your can find in the .phpcs.xml
.
Your can check PHPCS using a CLI:
or
Pay attention, tests have a bit another coding standards because testing libraries all using camelCase format for methods, function, variables, and properties.
PHPCS checked before each commit, before the push, and in GH Actions.
JS Coding Standard (JSCS)
We use a default WordPress JSCS, but you can modify it in the .eslintrc
file.
You can check JSCS using a CLI:
SCSS Coding Standard (SCSSCS)
We use a default standards for SCSS, but you can modify it in the .stylelintrc
file.
You can check SCSSCS using a CLI:
Environments
For any constants you can create the .env.development
and .env.production
files. For example, we use these constants from the .env.example
file for the browserSync inside the Laravel Mix config and for acceptance tests.
Frontend
All assets are located in assets/src/*
.
All builds are located in assets/build/*
.
CSS preprocessor is SCSS.
We use Laravel Mix for the assets build. You can modify it in .webpack.mix.js
file.
For run Laravel mix you can use the next commands depend on situation:
GitHub
GH Actions
All steps for GH Actions you can find in .github/workflows/plugin-name.yml
file. Also, for wake up a webserver, we need to add .github/workflows/plugin-name.conf
GH Hooks
Just make you GH repository clear. We use the Husky library to add actions before commit, push, etc. This helps developers make their GH more clear.
GH Templates
Basic GH templates for better security issues, support requests, bug reports, enhancements, feature requests, pull requests, and contributing templates.
Dependency injection container
The lightweight Dependency Injection component implements a PSR-11 compatible service container that allows you to standardize and centralize the way objects are constructed in your application.
Automatic load your dependencies using the type hinting.
You can disable plugin hooks very easily using a DIC. Just get the plugin object from the dependency injection container $container_builder->get( PluginName\Front\Front::class )
. Example just disabling frontend assets:
PHP Scoper
You need to add prefixes for each outside dependency because other plugins or themes can use the same dependencies, and it can conflict between packages.
Automated testing
We are using for automated testing a Codeception library runs all types of PHP tests.
PHP unit tests
For running use a CLI command:
- Main configuration file
.tests/php/unit.suite.yml
- Unit tests inside
.tests/php/unit/*
folder. - Bootstrap file
.tests/php/unit/_bootstrap.php
- Each filename for test class must have a suffix on
*Test.php
. - Each test class must extend a
PluginNameUnitTests\TestCase
class. - You can also add some code to
PluginNameUnitTests\TestCase.php
- Each test method must have prefix
test_
- Additional files for autoloading in tests running you can add to
.codeception/_support/*
folder.
Also, unit tests will be checked on a push to repository action and inside the GH Actions pipeline.
PHP acceptance tests
Warning! The acceptance tests make REAL actions on your site. Before running need to create another database and create a dump.sql
file with fresh WP install.
Before running, you need to (It needs to make just one time. I hope you can do it):
- Install a ChromeDriver
- Create a new database. For example, I named a database
codeception_db
- Install a clear WordPress
- Export database to
dump.sql
- Move a
dump.sql
file to the.codeception/_data/
folder. - Copy a file
.codeception/_config/params.example.php
to.codeception/_config/params.local.php
. - Update your connection information to the testing site connection in
.codeception/_config/params.local.php
file. - Update your
wp-config.php
file:
For running use a CLI command:
- Main configuration file
.tests/php/acceptance.suite.yml
- Unit tests inside
.tests/php/acceptace/*
folder. - Each filename for test class must have a suffix on
*Cest.php
. - Each test method must have prefix
test_
- Each test method must include
AcceptanceTester
as argument. - You can add some methods to AcceptanceTester in
.codeception/_support/AcceptanceTests.php
. - Additional files for autoload in tests running you can add to
.codeception/_support/*
folder.
JS unit tests
For running use a CLI command:
- Main configuration inside
.tests/js/package.json
in directoryjest
- Unit tests inside
.tests/js/unit/*
folder. - Bootstrap file
.tests/js/setupTests.js
- Each filename for test class must have a suffix on
*.test.js
. - Just import your class for testing and write tests.
Also, unit tests will be checked on a push to repository action and inside the GH Actions pipeline.