From 43ef462ccbf6903c6ef3bca1b56e3a4b0e9050d6 Mon Sep 17 00:00:00 2001 From: mejta Date: Mon, 26 Jun 2023 14:15:32 +0200 Subject: [PATCH 1/7] Add PHP/DI and basic functionality --- README.md | 14 +- bootstrap.php | 95 ++++++++++ composer.json | 20 ++ composer.lock | 262 ++++++++++++++++++++++++++ src/Managers/PostTypesManager.php | 13 ++ src/Managers/TaxonomiesManager.php | 12 ++ src/Plugin.php | 53 ++++++ src/PostTypes/BookPostType.php | 69 +++++++ src/Taxonomies/BookAuthorTaxonomy.php | 57 ++++++ 9 files changed, 594 insertions(+), 1 deletion(-) create mode 100644 bootstrap.php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 src/Managers/PostTypesManager.php create mode 100644 src/Managers/TaxonomiesManager.php create mode 100644 src/Plugin.php create mode 100644 src/PostTypes/BookPostType.php create mode 100644 src/Taxonomies/BookAuthorTaxonomy.php diff --git a/README.md b/README.md index e06a840..2185ab5 100644 --- a/README.md +++ b/README.md @@ -1 +1,13 @@ -# WPify Plugin tutorial +# Example WPify Plugin tutorial + +This is an example plugin to demostrate how we at WPify create plugins. + +## Installation + +1. Upload the plugin to the `/wp-content/plugins/` directory +2. Activate the plugin through the 'Plugins' menu in WordPress +3. Enjoy! + +## The goal of the plugin + +The aim is to create an diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..ab388f9 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,95 @@ +addDefinitions( array() ); + $container = $containerBuilder->build(); + } + + return $container; +} + +/** + * Returns the main plugin class from DI container. + * + * @return Plugin + * @throws DependencyException + * @throws NotFoundException + */ +function wpifypt(): Plugin { + return wpifypt_container()->get( Plugin::class ); +} + +/** + * Method called on plugin activation. + * + * @param $network_wide Plugin Activated network wide. + * + * @return void + * @throws DependencyException + * @throws NotFoundException + */ +function wpifypt_activate( $network_wide ): void { + wpifypt()->activate( $network_wide ); +} + +/** + * Method called on plugin deactivation. + * + * @param $network_wide Plugin Deactivated network wide. + * + * @return void + * @throws DependencyException + * @throws NotFoundException + */ +function wpifypt_deactivate( $network_wide ): void { + wpifypt()->deactivate( $network_wide ); +} + +/** + * Method called on plugin uninstall. + * + * @return void + * @throws DependencyException + * @throws NotFoundException + */ +function wpifypt_uninstall(): void { + wpifypt()->uninstall(); +} + +add_action( 'plugins_loaded', 'wpifypt' ); + +register_activation_hook( __FILE__, 'wpifypt_activate' ); +register_deactivation_hook( __FILE__, 'wpifypt_deactivate' ); +register_uninstall_hook( __FILE__, 'wpifypt_uninstall' ); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3c63f0e --- /dev/null +++ b/composer.json @@ -0,0 +1,20 @@ +{ + "name": "wpify/plugin-tutorial", + "type": "project", + "license": "MIT", + "autoload": { + "psr-4": { + "WpifyPluginTutorial\\": "src/" + } + }, + "authors": [ + { + "name": "WPify", + "email": "info@wpify.io" + } + ], + "require": { + "php": "^8.0", + "php-di/php-di": "^7.0" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..e594297 --- /dev/null +++ b/composer.lock @@ -0,0 +1,262 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "90b56d72733772cf33a0abb5cbb9ff3d", + "packages": [ + { + "name": "laravel/serializable-closure", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/serializable-closure.git", + "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", + "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0" + }, + "require-dev": { + "nesbot/carbon": "^2.61", + "pestphp/pest": "^1.21.3", + "phpstan/phpstan": "^1.8.2", + "symfony/var-dumper": "^5.4.11" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Laravel\\SerializableClosure\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + }, + { + "name": "Nuno Maduro", + "email": "nuno@laravel.com" + } + ], + "description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.", + "keywords": [ + "closure", + "laravel", + "serializable" + ], + "support": { + "issues": "https://github.com/laravel/serializable-closure/issues", + "source": "https://github.com/laravel/serializable-closure" + }, + "time": "2023-01-30T18:31:20+00:00" + }, + { + "name": "php-di/invoker", + "version": "2.3.3", + "source": { + "type": "git", + "url": "https://github.com/PHP-DI/Invoker.git", + "reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/cd6d9f267d1a3474bdddf1be1da079f01b942786", + "reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "psr/container": "^1.0|^2.0" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "mnapoli/hard-mode": "~0.3.0", + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Invoker\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Generic and extensible callable invoker", + "homepage": "https://github.com/PHP-DI/Invoker", + "keywords": [ + "callable", + "dependency", + "dependency-injection", + "injection", + "invoke", + "invoker" + ], + "support": { + "issues": "https://github.com/PHP-DI/Invoker/issues", + "source": "https://github.com/PHP-DI/Invoker/tree/2.3.3" + }, + "funding": [ + { + "url": "https://github.com/mnapoli", + "type": "github" + } + ], + "time": "2021-12-13T09:22:56+00:00" + }, + { + "name": "php-di/php-di", + "version": "7.0.3", + "source": { + "type": "git", + "url": "https://github.com/PHP-DI/PHP-DI.git", + "reference": "d5dad2500f409d8b78371823c8b382fe9b5d0917" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/d5dad2500f409d8b78371823c8b382fe9b5d0917", + "reference": "d5dad2500f409d8b78371823c8b382fe9b5d0917", + "shasum": "" + }, + "require": { + "laravel/serializable-closure": "^1.0", + "php": ">=8.0", + "php-di/invoker": "^2.0", + "psr/container": "^1.1 || ^2.0" + }, + "provide": { + "psr/container-implementation": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3", + "friendsofphp/proxy-manager-lts": "^1", + "mnapoli/phpunit-easymock": "^1.3", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.6" + }, + "suggest": { + "friendsofphp/proxy-manager-lts": "Install it if you want to use lazy injection (version ^1)" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "DI\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The dependency injection container for humans", + "homepage": "https://php-di.org/", + "keywords": [ + "PSR-11", + "container", + "container-interop", + "dependency injection", + "di", + "ioc", + "psr11" + ], + "support": { + "issues": "https://github.com/PHP-DI/PHP-DI/issues", + "source": "https://github.com/PHP-DI/PHP-DI/tree/7.0.3" + }, + "funding": [ + { + "url": "https://github.com/mnapoli", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/php-di/php-di", + "type": "tidelift" + } + ], + "time": "2023-06-17T10:21:14+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^8.0" + }, + "platform-dev": [], + "plugin-api-version": "2.3.0" +} diff --git a/src/Managers/PostTypesManager.php b/src/Managers/PostTypesManager.php new file mode 100644 index 0000000..7e006bf --- /dev/null +++ b/src/Managers/PostTypesManager.php @@ -0,0 +1,13 @@ + _x( 'Books', 'Post Type General Name', 'wpifypt' ), + 'singular_name' => _x( 'Book', 'Post Type Singular Name', 'wpifypt' ), + 'menu_name' => __( 'Books', 'wpifypt' ), + 'name_admin_bar' => __( 'Book', 'wpifypt' ), + 'archives' => __( 'Book Archives', 'wpifypt' ), + 'attributes' => __( 'Book Attributes', 'wpifypt' ), + 'parent_item_colon' => __( 'Parent Book:', 'wpifypt' ), + 'all_items' => __( 'All Books', 'wpifypt' ), + 'add_new_item' => __( 'Add New Book', 'wpifypt' ), + 'add_new' => __( 'Add New', 'wpifypt' ), + 'new_item' => __( 'New Book', 'wpifypt' ), + 'edit_item' => __( 'Edit Book', 'wpifypt' ), + 'update_item' => __( 'Update Book', 'wpifypt' ), + 'view_item' => __( 'View Book', 'wpifypt' ), + 'view_items' => __( 'View Books', 'wpifypt' ), + 'search_items' => __( 'Search Book', 'wpifypt' ), + 'not_found' => __( 'Not found', 'wpifypt' ), + 'not_found_in_trash' => __( 'Not found in Trash', 'wpifypt' ), + 'featured_image' => __( 'Featured Image', 'wpifypt' ), + 'set_featured_image' => __( 'Set featured image', 'wpifypt' ), + 'remove_featured_image' => __( 'Remove featured image', 'wpifypt' ), + 'use_featured_image' => __( 'Use as featured image', 'wpifypt' ), + 'insert_into_item' => __( 'Insert into book', 'wpifypt' ), + 'uploaded_to_this_item' => __( 'Uploaded to this book', 'wpifypt' ), + 'items_list' => __( 'Books list', 'wpifypt' ), + 'items_list_navigation' => __( 'Books list navigation', 'wpifypt' ), + 'filter_items_list' => __( 'Filter books list', 'wpifypt' ), + ); + + $args = array( + 'label' => __( 'Book', 'wpifypt' ), + 'description' => __( 'Example post type Book', 'wpifypt' ), + 'labels' => $labels, + 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ), + 'taxonomies' => array( BookAuthorTaxonomy::KEY ), + 'hierarchical' => false, + 'public' => true, + 'show_ui' => true, + 'show_in_menu' => true, + 'menu_position' => 25, + 'menu_icon' => 'dashicons-book', + 'show_in_admin_bar' => true, + 'show_in_nav_menus' => true, + 'can_export' => true, + 'has_archive' => true, + 'exclude_from_search' => false, + 'publicly_queryable' => true, + 'capability_type' => 'page', + 'show_in_rest' => false, + ); + + register_post_type( self::KEY, $args ); + } +} diff --git a/src/Taxonomies/BookAuthorTaxonomy.php b/src/Taxonomies/BookAuthorTaxonomy.php new file mode 100644 index 0000000..321646a --- /dev/null +++ b/src/Taxonomies/BookAuthorTaxonomy.php @@ -0,0 +1,57 @@ + _x( 'Book Authors', 'Taxonomy General Name', 'wpifypt' ), + 'singular_name' => _x( 'Book Author', 'Taxonomy Singular Name', 'wpifypt' ), + 'menu_name' => __( 'Book Author', 'wpifypt' ), + 'all_items' => __( 'All Book Authors', 'wpifypt' ), + 'parent_item' => __( 'Parent Book Author', 'wpifypt' ), + 'parent_item_colon' => __( 'Parent Book Author:', 'wpifypt' ), + 'new_item_name' => __( 'New Book Author', 'wpifypt' ), + 'add_new_item' => __( 'Add Book Author', 'wpifypt' ), + 'edit_item' => __( 'Edit Book Author', 'wpifypt' ), + 'update_item' => __( 'Update Book Author', 'wpifypt' ), + 'view_item' => __( 'View Book Author', 'wpifypt' ), + 'separate_items_with_commas' => __( 'Separate items with commas', 'wpifypt' ), + 'add_or_remove_items' => __( 'Add or remove book authors', 'wpifypt' ), + 'choose_from_most_used' => __( 'Choose from the most used', 'wpifypt' ), + 'popular_items' => __( 'Popular Book Authors', 'wpifypt' ), + 'search_items' => __( 'Search Book Authors', 'wpifypt' ), + 'not_found' => __( 'Not Found', 'wpifypt' ), + 'no_terms' => __( 'No Book Authors', 'wpifypt' ), + 'items_list' => __( 'Book Authors list', 'wpifypt' ), + 'items_list_navigation' => __( 'Book Authors list navigation', 'wpifypt' ), + ); + + $rewrite = array( + 'slug' => 'book-author', + 'with_front' => true, + 'hierarchical' => false, + ); + + $args = array( + 'labels' => $labels, + 'hierarchical' => false, + 'public' => true, + 'show_ui' => true, + 'show_admin_column' => true, + 'show_in_nav_menus' => true, + 'show_tagcloud' => true, + 'rewrite' => $rewrite, + ); + + register_taxonomy( self::KEY, array( BookPostType::KEY ), $args ); + } +} From acad48e57569775eff0fc0ffa3c890df1980dd1b Mon Sep 17 00:00:00 2001 From: mejta Date: Mon, 26 Jun 2023 14:17:50 +0200 Subject: [PATCH 2/7] Add PHP/DI and basic functionality --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2185ab5..7ddd0a4 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,5 @@ This is an example plugin to demostrate how we at WPify create plugins. ## The goal of the plugin -The aim is to create an +The aim is to create simple plugin that stores information about books and their authors. On this, we demonstrate +the advanced techniques of creating a plugin. From cf1492243ffdf78c234891f78ac3ff03ca3916d8 Mon Sep 17 00:00:00 2001 From: mejta Date: Mon, 26 Jun 2023 14:20:36 +0200 Subject: [PATCH 3/7] Add PHP/DI and basic functionality --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 7ddd0a4..4334a6a 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,14 @@ This is an example plugin to demostrate how we at WPify create plugins. The aim is to create simple plugin that stores information about books and their authors. On this, we demonstrate the advanced techniques of creating a plugin. + +## Steps: + +### 01 - PHP/DI + +in this step, we will add PHP/DI to the plugin. This will allow us to use dependency injection in our plugin. +Also, the basic structure of the plugin will be created. + +```bash +composer require php-di/php-di +``` From 7cc9bdc6d2fdfcf048bede266dd595d9b5d25ef0 Mon Sep 17 00:00:00 2001 From: mejta Date: Mon, 26 Jun 2023 14:29:35 +0200 Subject: [PATCH 4/7] Update --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4334a6a..cdcdd79 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Example WPify Plugin tutorial -This is an example plugin to demostrate how we at WPify create plugins. +This is an example plugin to demonstrate how we at WPify create plugins. ## Installation @@ -20,6 +20,8 @@ the advanced techniques of creating a plugin. in this step, we will add PHP/DI to the plugin. This will allow us to use dependency injection in our plugin. Also, the basic structure of the plugin will be created. +Links: [PHP/DI](https://php-di.org/) + ```bash composer require php-di/php-di ``` From 876f2106897d09d65e9c976dddd026198b8f39ec Mon Sep 17 00:00:00 2001 From: mejta Date: Mon, 26 Jun 2023 16:21:09 +0200 Subject: [PATCH 5/7] Add assets, utils --- .gitignore | 1 + composer.lock | 262 -------------------------------------------------- 2 files changed, 1 insertion(+), 262 deletions(-) delete mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 58f394d..e0c6366 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor/ .DS_Store +composer.lock diff --git a/composer.lock b/composer.lock deleted file mode 100644 index e594297..0000000 --- a/composer.lock +++ /dev/null @@ -1,262 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "90b56d72733772cf33a0abb5cbb9ff3d", - "packages": [ - { - "name": "laravel/serializable-closure", - "version": "v1.3.0", - "source": { - "type": "git", - "url": "https://github.com/laravel/serializable-closure.git", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", - "shasum": "" - }, - "require": { - "php": "^7.3|^8.0" - }, - "require-dev": { - "nesbot/carbon": "^2.61", - "pestphp/pest": "^1.21.3", - "phpstan/phpstan": "^1.8.2", - "symfony/var-dumper": "^5.4.11" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Laravel\\SerializableClosure\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - }, - { - "name": "Nuno Maduro", - "email": "nuno@laravel.com" - } - ], - "description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.", - "keywords": [ - "closure", - "laravel", - "serializable" - ], - "support": { - "issues": "https://github.com/laravel/serializable-closure/issues", - "source": "https://github.com/laravel/serializable-closure" - }, - "time": "2023-01-30T18:31:20+00:00" - }, - { - "name": "php-di/invoker", - "version": "2.3.3", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/Invoker.git", - "reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/cd6d9f267d1a3474bdddf1be1da079f01b942786", - "reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "psr/container": "^1.0|^2.0" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "mnapoli/hard-mode": "~0.3.0", - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Invoker\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Generic and extensible callable invoker", - "homepage": "https://github.com/PHP-DI/Invoker", - "keywords": [ - "callable", - "dependency", - "dependency-injection", - "injection", - "invoke", - "invoker" - ], - "support": { - "issues": "https://github.com/PHP-DI/Invoker/issues", - "source": "https://github.com/PHP-DI/Invoker/tree/2.3.3" - }, - "funding": [ - { - "url": "https://github.com/mnapoli", - "type": "github" - } - ], - "time": "2021-12-13T09:22:56+00:00" - }, - { - "name": "php-di/php-di", - "version": "7.0.3", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/PHP-DI.git", - "reference": "d5dad2500f409d8b78371823c8b382fe9b5d0917" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/d5dad2500f409d8b78371823c8b382fe9b5d0917", - "reference": "d5dad2500f409d8b78371823c8b382fe9b5d0917", - "shasum": "" - }, - "require": { - "laravel/serializable-closure": "^1.0", - "php": ">=8.0", - "php-di/invoker": "^2.0", - "psr/container": "^1.1 || ^2.0" - }, - "provide": { - "psr/container-implementation": "^1.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3", - "friendsofphp/proxy-manager-lts": "^1", - "mnapoli/phpunit-easymock": "^1.3", - "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^4.6" - }, - "suggest": { - "friendsofphp/proxy-manager-lts": "Install it if you want to use lazy injection (version ^1)" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "DI\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "The dependency injection container for humans", - "homepage": "https://php-di.org/", - "keywords": [ - "PSR-11", - "container", - "container-interop", - "dependency injection", - "di", - "ioc", - "psr11" - ], - "support": { - "issues": "https://github.com/PHP-DI/PHP-DI/issues", - "source": "https://github.com/PHP-DI/PHP-DI/tree/7.0.3" - }, - "funding": [ - { - "url": "https://github.com/mnapoli", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/php-di/php-di", - "type": "tidelift" - } - ], - "time": "2023-06-17T10:21:14+00:00" - }, - { - "name": "psr/container", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "shasum": "" - }, - "require": { - "php": ">=7.4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/2.0.2" - }, - "time": "2021-11-05T16:47:00+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": "^8.0" - }, - "platform-dev": [], - "plugin-api-version": "2.3.0" -} From f99271f5b1e7d2265144a46b8a4e33a8be8cade9 Mon Sep 17 00:00:00 2001 From: mejta Date: Mon, 26 Jun 2023 17:21:45 +0200 Subject: [PATCH 6/7] Update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cdcdd79..857db0a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ the advanced techniques of creating a plugin. ### 01 - PHP/DI -in this step, we will add PHP/DI to the plugin. This will allow us to use dependency injection in our plugin. +in this step, we will add PHP-DI to the plugin. This will allow us to use dependency injection in our plugin. Also, the basic structure of the plugin will be created. Links: [PHP/DI](https://php-di.org/) From 7b9331da1a66b2c7405eed0faa0237f35faaefd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Greif?= Date: Mon, 26 Jun 2023 19:51:55 +0200 Subject: [PATCH 7/7] Readme --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 857db0a..bf84bdc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Example WPify Plugin tutorial -This is an example plugin to demonstrate how we at WPify create plugins. +This is an example plugin to demonstrate how we at WPify create plugins. ## Installation @@ -15,12 +15,17 @@ the advanced techniques of creating a plugin. ## Steps: -### 01 - PHP/DI +### 01 - Basic concepts - OOP, Namespaces, Composer, Dependency Injection -in this step, we will add PHP-DI to the plugin. This will allow us to use dependency injection in our plugin. -Also, the basic structure of the plugin will be created. +Let's start with building the basic plugin structure using OOP, Namespaces, Composer and Dependency Injection. -Links: [PHP/DI](https://php-di.org/) +Links: + +* [Object oriented programming - OOP](https://www.phptutorial.net/php-oop/) +* [Namespaces](https://www.phptutorial.net/php-oop/php-namespace/) +* [Composer](https://getcomposer.org/doc/01-basic-usage.md) +* [Understanding Dependency Injection](https://php-di.org/doc/understanding-di.html) +* DI Containers - [PHP/DI](https://php-di.org/), [Symfony DI](https://symfony.com/doc/current/components/dependency_injection.html), [League](https://container.thephpleague.com/), [Nette](https://doc.nette.org/en/dependency-injection/container), [Dice](https://github.com/Level-2/Dice) ```bash composer require php-di/php-di