{"id":18759878,"url":"https://github.com/npbtrac/wp-plugin-enpii-base","last_synced_at":"2025-09-01T16:32:44.665Z","repository":{"id":37558236,"uuid":"141961684","full_name":"npbtrac/wp-plugin-enpii-base","owner":"npbtrac","description":"Enpii Base plugin to WordPress development, this requires ACF plugin to work","archived":false,"fork":false,"pushed_at":"2024-11-12T23:25:56.000Z","size":39736,"stargazers_count":1,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-14T18:55:10.595Z","etag":null,"topics":["composer-package","wordpress","wordpress-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npbtrac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-07-23T04:36:47.000Z","updated_at":"2023-12-15T18:07:13.000Z","dependencies_parsed_at":"2023-12-05T05:26:44.674Z","dependency_job_id":"f2f77798-e94f-4d7b-acaf-85f28ffc3f23","html_url":"https://github.com/npbtrac/wp-plugin-enpii-base","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npbtrac%2Fwp-plugin-enpii-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npbtrac%2Fwp-plugin-enpii-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npbtrac%2Fwp-plugin-enpii-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npbtrac%2Fwp-plugin-enpii-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npbtrac","download_url":"https://codeload.github.com/npbtrac/wp-plugin-enpii-base/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231701629,"owners_count":18413419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer-package","wordpress","wordpress-plugin"],"created_at":"2024-11-07T18:08:10.922Z","updated_at":"2024-12-29T04:33:54.257Z","avatar_url":"https://github.com/npbtrac.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Installation\n- Commands to set up the development environment\n```shell script\ncp .env.example .env\ndocker pull composer\ndocker run --rm --interactive --tty --volume $PWD:/app composer composer install\ndocker-compose up -d\n```\n- Run the WP CLI command to prepare the necessary things\n```\ndocker-compose exec wordpress wp enpii-base prepare_wp_app\n```\n\n## Explaination\n- `dev-docker` is the folder for docker related stuffs\n- `dev-docker/wordpress` would be the document root for the webserver default host (it's `/var/www/html` in the container)\n- In the container `wordpress`\n\t- `devuser` is the user to own the files and folder\n\t- `nobody` is ths user of the webserver (for uploading files or create files using the web requests)\n\n## Working with the containers\n- To SSH to the wordpress containers\n```\ndocker-compose exec --user=devuser wordpress sh\n```\n\nThe local website will work with http://127.0.0.1:10108/ (or the port you put in env file)\n\n## Development\n- Remember to enable git case sensitive for files\n```\ngit config core.ignorecase false\n```\n- Add `XDEBUG_MODE=off` before `composer` to turn off XDebug to speedup the composer\n\n### Base concepts\n  - This plugin will create a laravel application `wp_app()` (a DI container https://code.tutsplus.com/tutorials/digging-in-to-laravels-ioc-container--cms-22167) contains everything we need.\n  - Each plugin or theme will act as a Service Provider https://laravel.com/docs/7.x/providers\n  - We are trying to implement Domain Driven Development (DDD) and Command Query Responsibility Segregation (CQRS)\n    - Code sample here https://github.com/mguinea/laravel-ddd-example\n    - More on DDD https://content-garden.com/domain-driven-design-ddd-principles-with-laravel\n\t- More on CQRS https://tsh.io/blog/cqrs-event-sourcing-php/, https://github.com/artisansdk/cqrs\n  - Each handler is a class (1 class only for 1 handler). An action may contain many hanlders.\n\n### Working with composer\n- We should use `~1.0.3` when require a package (only update if bugfixing released)\n- We use `mozart` (https://packagist.org/packages/coenjacobs/mozart) package to put the dependencies to a separate folder for the plugin to avoid the conflicts\n  - We should use `mozart` globally\n  - After running `composer update`, you need to run `mozart compose` (this should be run manually). If issues found related to some composer issues e.g. wrong included files, wrong path (due to the moving of files) ... you need to run `composer update` (or `composer dump-autoload`) one more time after fixing `composer.json` file.\n- In case we want to upgrade laravel framework (it's a crazy thing), you need to add `\"laravel/framework\": \"7.30.6\"` to the dependencies then remove that line and `composer.lock` after running mozart then run `composer update` again.\n\n#### Process to perform the composer and mozart:\n  - Remove the `autoload -\u003e files` part in composer.json\n  - `XDEBUG_MODE=off composer install` or `XDEBUG_MODE=off composer update`\n  - `composer dump-autoload`\n  - `mozart compose`\n  - Undo the removing `autoload -\u003e files`\n  - `composer dump-autoload`\n\nOr you can do the alternative way\n  - `XDEBUG_MODE=off composer install --no-autoloader` or `XDEBUG_MODE=off composer update --no-autoloader`\n  - `mozart compose`\n  - `composer dump-autoload`\n\n#### After using `mozart`, remember to manually repair the namespace in:\n  - `LogManager`, use namespace `as Monolog`\n  - `ParseLogConfiguration` (same as above)\n  - `Symfony\\Component\\Routing\\Route`, find the keyword `compiler_class` and update that option value to the one with the namespace\n  - Replace all `app()` -\u003e `wp_app()`, `collect()` -\u003e `wp_app_collect()`\n\n### Naming Convention\n- Spaces, indentation are defined in `.editorconfig`\n- We follow WordPress conventions https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions\n\t- Variables, functions, methods should be named in **snake_eye** rules e.g. `$current_date`, `get_latest_posts` (not `$currentDate` or `getLatestPosts`)\n\t- Classes, Traits, Interfaces, enum names should be named with capitalized words separated by underscores e.g. `Top_Gun`, `A_Simple_Payment_Gateway` (not `TopGun` or `ASimplePaymentGateway`)\n- Running **phpcs** to find coding standard issues\n\t- With docker (we need to use php 7.4 to avoid errors)\n\t```shell script\n\t# Run the docker pull once if you haven't run that before\n\tdocker pull npbtrac/php:7.4-x86\n\t# For arm\n\t# docker pull npbtrac/php:7.4-arm\n\tdocker run --rm --interactive --tty -v $PWD:/var/www/html npbtrac/php:7.4-arm ./vendor/bin/phpcs\n\t```\n\t- Or if you have your executable php 7.4 on your machine (we need to use php 7.4 to avoid errors)\n\t```shell script\n\t/path/to/your/php7.4/executable/file ./vendor/bin/phpcs\n\t```\n- Running **phpcbf** to fix code style issues\n\t- With docker (we need to use php 7.4 to avoid errors)\n\t```shell script\n\t# Run the docker pull once if you haven't run that before\n\tdocker pull serversideup/php:8.0-cli\n\tdocker run --rm --interactive --tty -v $PWD:/var/www/html serversideup/php:8.0-cli ./vendor/bin/phpcbf \u003cpath-to-file-need-to-be-fixed\u003e\n\t```\n\t- Or if you have your executable php 7.4 on your machine (we need to use php 7.4 to avoid errors)\n\t```shell script\n\t/path/to/your/php8.0/executable/file ./vendor/bin/phpcbf \u003cpath-to-file-need-to-be-fixed\u003e\n\t```\n### Testing\n- To run unit test\n```\ncomposer codecept unit\n```\n\n### Install plugins and themes via the WP Admin Dashbboard\n- We need to ensure needed folders are there (only run once)\n```shell script\ndocker compose exec --user=devuser wordpress mkdir -p /var/www/html/wp-content/uploads \u003e/dev/null 2\u003e\u00261\ndocker compose exec --user=devuser wordpress mkdir -p /var/www/html/wp-content/upgrade \u003e/dev/null 2\u003e\u00261\ndocker compose exec --user=devuser wordpress mkdir -p /var/www/html/wp-content/cache \u003e/dev/null 2\u003e\u00261\ndocker compose exec --user=devuser wordpress chmod -R 777 /var/www/html/wp-content/cache /var/www/html/wp-content/uploads /var/www/html/wp-content/upgrade\n```\n- To install plugins and themes via the Admin Dashboard, you need to follow these steps:\n\t1. Add this part to `wp-config.php` (after `That's all ... ` line)\n\t```\n\tdefine( 'FS_METHOD', 'direct' );\n\tdefine( 'FS_CHMOD_DIR', (0755 \u0026 ~ umask()) );\n\tdefine( 'FS_CHMOD_FILE', (0644 \u0026 ~ umask()) );\n\t```\n\t2. Allow the file writting folders first\n\tFor plugins:\n\t```shell script\n\tdocker compose exec --user=devuser wordpress chmod g+w /var/www/html/wp-content/plugins/\n\t```\n\n\tFor themes:\n\t```shell script\n\tdocker compose exec --user=devuser wordpress chmod g+w /var/www/html/wp-content/themes/\n\t```\n\n\t3. Start to perform plugins, themes installation\n\n\t4. Revoke the write permission\n\t```shell script\n\tdocker compose exec --user=devuser wordpress chmod g-w /var/www/html/wp-content/plugins/\n\tdocker compose exec --user=devuser wordpress chmod g-w /var/www/html/wp-content/themes/\n\t```\n\n\t5. Remove the previous part added to `wp-config.php` (item 1)\n\n## License\n\nThe Enpii Base plugin is open-sourced software licensed under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpbtrac%2Fwp-plugin-enpii-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpbtrac%2Fwp-plugin-enpii-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpbtrac%2Fwp-plugin-enpii-base/lists"}