Skip to content

Commit

Permalink
Merge pull request #3 from Pink-Crab/feature/create-1.0.0
Browse files Browse the repository at this point in the history
Feature/create 1.0.0
  • Loading branch information
gin0115 authored Jun 12, 2021
2 parents 82fce98 + 497b32c commit 43c3cf3
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 34 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PinkCrab Plugin Boilerplate *V0.4* #
# PinkCrab Perique Boilerplate V1.0.0 #


Welcome to the PinkCrab Plugin Boilerplate. The PinkCrab Plugin Framework give you all the basic tools needed to make a MVC style plugins for WordPress. Comes with a DI Container (DICE), custom Hook Loader and extendable registration process for interacting with WP apis.
Welcome to the Perique Boilerplate. The Perique Framework give you all the basic tools needed to make a MVC style plugins for WordPress. Comes with a DI Container (DICE), custom Hook Loader and extendable registration process for interacting with WP apis.

## Setup

Expand All @@ -14,7 +14,7 @@ These are the placeholders currently in place that will need changing before run

| Placeholder | Description | Files |
| --- | ----------- | --- |
| ##PACKAGE_NAME## | Should be in valid composer format *achme/my-plugin* | composer.json |
| ##PACKAGE_NAME## | Should be in valid composer format *achme/my-plugin* | composer.json & settings.php |
| ##DESCRIPTION## | This is your plugins description | composer.json & plugin.php |
| ##YOUR URL## | Replace with your own homepage or github profile | composer.json & plugin.php |
| ##AUTHOR## | The name of the primary developer, you can add more authors if you wish to composer.json | composer.json & plugin.php |
Expand All @@ -33,19 +33,19 @@ These are the placeholders currently in place that will need changing before run

## Packages

The PinkCrab Plugin Framework allows the use of composer packages, which can be added as normal. However care should be take to ensure that you only add dependencies if you have 100% control over the codebase. You might be using the latest and greatest version of a package and another plugin uses a older version. Before you know it you have some fun and games with dependency conflicts. We used to package a full build suite using PHP Scoper to rename package namespaces, but we have removed it from this basic boilerplate.
Perique allows the use of composer packages, which can be added as normal. However care should be take to ensure that you only add dependencies if you have 100% control over the codebase. You might be using the latest and greatest version of a package and another plugin uses a older version. Before you know it you have some fun and games with dependency conflicts. We used to package a full build suite using PHP-Scoper to rename package namespaces, but we have removed it from this basic boilerplate.

## Tests

Out of the box, this boilerplate comes with PHPUnit, PHPStan and PHPCS. All 3 are come with prepopulated config files, allow you to hit the ground running. If you look into the composer.json file you will find we have a selection of commands you can run.
Out of the box, this boilerplate comes with PHPUnit, PHPStan and PHPCS. All 3 are come with pre-populated config files, allow you to hit the ground running. If you look into the composer.json file you will find we have a selection of commands you can run.

* **composer test** This will run phpunit on its own, generating the coverage report and giving the testdox output
* **composer coverage** This will run phpunit and generate a full HTML report of coverage in ```/coverage-report```
* **composer analyse** This will run PHPStan at lv8 over all code in the src/ directory. Package includes WordPress Core, WooCommerce and ACF stubs~
* **composer sniff** This run the the code found in /src through PHPCS using the ruleset defined in phpcs.xml
* **composer all** This will composer test then composer analyse and finally composer sniff.

~ To use the WooCommerce and ACF stubs, please remvoe the # from ```phpstan.neon.dist```
~ To use the WooCommerce and ACF stubs, please remove the # from ```phpstan.neon.dist```

## GitHub Actions

Expand All @@ -57,7 +57,7 @@ As mentioned the Boilerplate comes with WPUnit included and will install a versi

## File Structure

This Boilerplate is faily agnostic where and how you structure your code. Out of the box, this Boilerplate is set up with the following assumptions
This Boilerplate is fairly agnostic where and how you structure your code. Out of the box, this Boilerplate is set up with the following assumptions

```bash
| /.github # Holds the github actions files, should not be moved!
Expand All @@ -67,13 +67,13 @@ This Boilerplate is faily agnostic where and how you structure your code. Out of
| /tests # Holds all PHPUnit and WP_Unit config files and tests themselves.
| /views # Holds all template files
| composer.json # The composer configuration file.
| phpcs.xml # Defines the ruleset and custom rules for PHP-CS
| phpcs.xml # Defines the rule set and custom rules for PHP-CS
| phpstan.neon.dist # PHPStan definitions and stub declarations.
| phpunit.xml.dist # WP & PHPUnit configurations.
| plugin.php # The WP Plugin definition and app bootstrapping.
| README.md # You are here!

# Optional artifacts, all included in gitignore and gernated for/during testing.
# Optional artifacts, all included in gitignore and generated for/during testing.
| /coverage-report # The generated Coverage Report in HTML format.
| /wordpress # The test instance of WP used for WPUnit tests
| /vendor # Composer directory, should be uploaded with your code, but not needed in repo
Expand All @@ -82,8 +82,8 @@ This Boilerplate is faily agnostic where and how you structure your code. Out of

## Additional Docs

You can find out more information about the Plugin Framework on its own [repo](https://github.com/Pink-Crab/Plugin-Framework) or by visiting the [gitbook docs](https://glynn-quelch.gitbook.io/pinkcrab/).
You can find out more information about the Plugin Framework on its own [repo](https://github.com/Pink-Crab/Perqiue-Framework) or by visiting the [gitbook docs](https://glynn-quelch.gitbook.io/pinkcrab/).

## Contributions

If you would like to contribute to the PinkCrab Plugin Framework and/or any of its packages, please feel to reach out at [email protected] or generate an issue/pr over on github. This package is manually updated everytime we make substantial changes to the Core package.
If you would like to contribute to the Perique Framework and/or any of its packages, please feel to reach out at [email protected] or generate an issue/pr over on github. This package is manually updated every time we make substantial changes to the Core package.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
},
"require": {
"php": ">=7.1.0",
"pinkcrab/plugin-framework": "0.4.*"
"pinkcrab/perique-framework-core": "^1.0"
},
"scripts": {
"test": "phpunit --coverage-clover coverage.xml --testdox",
"coverage": "phpunit --coverage-html coverage-report --testdox",
"analyse": "vendor/bin/phpstan analyse src -l8",
"test": "./vendor/bin/phpunit --coverage-clover coverage.xml --testdox",
"coverage": "./vendor/bin/phpunit --coverage-html coverage-report --testdox",
"analyse": "./vendor/bin/phpstan analyse src -l8",
"sniff": "./vendor/bin/phpcs src/ -v",
"all": "composer test && composer analyse && composer sniff"
},
Expand Down
14 changes: 13 additions & 1 deletion config/dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,16 @@
* See docs at https://app.gitbook.com/@glynn-quelch/s/pinkcrab/application/dependency-injection
*/

return array();
return array(
// Sets the base path for views.
// If you are using a different views path, please update in PHP_Engine args
// Remove this if not planning to use the View or replace if using BladeOne
'*' => array(
'substitutions' => array(
PinkCrab\Perique\Interfaces\Renderable::class
=> new PinkCrab\Perique\Services\View\PHP_Engine(
\dirname( __DIR__, 1 ) . '/views'
),
),
),
);
4 changes: 2 additions & 2 deletions config/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
declare(strict_types=1);

/**
* List of classes passed through the registaion service.
* List of classes passed through the registration service.
* See docs at https://app.gitbook.com/@glynn-quelch/s/pinkcrab/application/registration
*/

return array(
/** Include all your classes which implemenet Registerable here */
/** Include all your classes which implement Registerable here */
);
45 changes: 33 additions & 12 deletions config/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

// Useful WP helpers
$wp_uploads = \wp_upload_dir();
global $wpdb;

// Include the plugins file for access plugin details before init.
if ( ! function_exists( 'get_plugin_data' ) ) {
Expand All @@ -28,31 +27,53 @@
'assets' => $base_path . '/assets',
'upload_root' => $wp_uploads['basedir'],
'upload_current' => $wp_uploads['path'],

// Include custom
// 'foo' => 'some/path',
// Will allow Config::path('foo') === 'some/path'
),
'url' => array(
'plugin' => \plugins_url( $plugin_dir ),
'view' => \plugins_url( $plugin_dir ) . '/views',
'assets' => \plugins_url( $plugin_dir ) . '/assets',
'upload_root' => $wp_uploads['baseurl'],
'upload_current' => $wp_uploads['url'],

// Include custom
// 'bar' => 'some/url',
// Will allow Config::url('bar') === 'some/path'
),
'post_types' => array(
// 'your_key' => array( // use with Config::post_types('your_key')
// 'slug' => 'cpt_slug',
// 'meta' => array(
// 'your_key' => 'meta_key',
// ),
// ),
// Use this to prefix your cpt types
// 'events' => 'pinkcrab_event',
// Will allow Config::post_types('events') === 'pinkcrab_event'
),
'taxonomies' => array(
// 'your_key' => array( // use with Config::taxonomies('your_key')
// 'slug' => 'tax_slug',
// 'term' => array(),
// ),
// Use this to prefix your taxonomies
// 'location' => 'pinkcrab_location',
// Will allow Config::taxonomies('location') === 'pinkcrab_location'
),
'meta' => array(
'post' => array(
// 'key_1' => 'pinkcrab_post_meta_key_1',
// Will allow Config::post_meta('key_1') === 'pinkcrab_post_meta_key_1'
),
'user' => array(
// 'key_1' => 'pinkcrab_user_meta_key_1',
// Will allow Config::user_meta('key_1') === 'pinkcrab_user_meta_key_1'
),
'term' => array(
// 'key_1' => 'pinkcrab_term_meta_key_1',
// Will allow Config::term_meta('key_1') === 'pinkcrab_term_meta_key_1'
),
),
'db_tables' => array(
// 'db' => $GLOBALS['wpdb']->prefix . 'db_table',
// Will allow Config::db_tables('db') === 'wp_db_table'
),
'plugin' => array(
'version' => is_array( $plugin_data ) && array_key_exists( 'Version', $plugin_data )
? $plugin_data['Version'] : '0.1.0',
? $plugin_data['Version'] : '0.1.0', // <- fallback version
),
'namespaces' => array(
'rest' => 'pinkcrab/boilerplate',
Expand Down
6 changes: 2 additions & 4 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
* TextDomain: ##TEXT DOMAIN##
*/

use PinkCrab\Core\Application\App_Factory;

require_once __DIR__ . '/vendor/autoload.php';

( new App_Factory() )->with_wp_dice( true )
$app = ( new PinkCrab\Perique\Application\App_Factory() )->with_wp_dice( true )
->di_rules( require __DIR__ . '/config/dependencies.php' )
->app_config( require __DIR__ . '/config/settings.php' )
->registration_classses( require __DIR__ . '/config/registration.php' )
->registration_classes( require __DIR__ . '/config/registration.php' )
->boot();

0 comments on commit 43c3cf3

Please sign in to comment.