Code Monkey home page Code Monkey logo

developer-manual's Introduction

Developer Manual

Table Of Contents

  1. PC Setup
  2. Git Set Up
  3. WordPress Coding Standard
  4. WordPress Plugin Development
  5. WordPress Theme Development
  6. WordPress Rest API Development
  7. Unit Testing
  8. React Tutorials
  9. GrumPHP

PC Setup

  1. IDE will be PHPStorm
    1. Import IDE Settings. Please visit the below link to import IDE settings.
    2. How to import IDE Settings
  2. Node.js LTS version, XAMPP or MAMP, Git
  3. If you're using macOS then install brew
  4. Create an account to atlassian for task management by JIRA software.
  5. Connect with official slack channel for communication with team.

GIT Setup

Then connect your git account with the current PC through SSH Key. Read this article to connect with your PC.

Adding a new SSH key to your GitHub account.

How to manage multiple GitHub accounts on a single machine with SSH keys

https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/

FOR SWITCHING ACCOUNT
Delete current ssk key 
ssh-add -D
setup new ssh key
ssh-add ~/.ssh/id_azizulhasan

Change username and email
Git config user.name “username”
Git config user.email “[email protected]

GitFlow Setup

Gitflow is an alternative Git branching model that involves the use of feature branches and multiple primary branches.

  1. GitFlow Installation
  2. GitFlow Cheat Sheet

WordPress Coding Standard

WordPress Coding Standards by WordPress must read documentation for coding standard.

Why have coding standards?

Coding standards help avoid common coding errors, improve the readability of code, and simplify modification. They ensure that files within the project appear as if they were created by a single person.

Following the standards means anyone will be able to understand a section of code and modify it, if needed, without regard to when it was written or by whom.

If you are planning to contribute to WordPress Core, you need to familiarize yourself with these standards, as any code you submit will need to comply with them.

Language-specific Standards

  1. CSS Coding Standards
  2. HTML Coding Standards
  3. JavaScript Coding Standards
  4. PHP Coding Standards

WordPress Coding Standards for PHP_CodeSniffer

WordPress Plugin Development

The best resource for learning about WordPress plugin development is Introduction to Plugin Development by WordPress. WebAppick provides and prefers developers to learn about WordPress plugin development from a tutorial by Hasin Hayder. Here is the link ওয়ার্ডপ্রেস প্লাগইন ডেভেলপমেন্ট.

Credentials:

username: 
password:

If these credentials are not working please ask for credentials to who are concern.

IMPORTANT TOPICS TO UNDERSTAND

  1. Plugin Security
    1. Check User Capability.
    2. Data Validation
    3. Data Sanitization
    4. Data Escaping
    5. Nonce
  2. Hooks
    1. Few Methods To Understand Hooks
    1. add_action()
    2. do_action()
    3. add_filter()
    4. apply_filter()
    5. has_filter()
    6. did_action()
    7. remove_filter()
    8. remove_action()
    9. current_action()
    10. current_filter()
    12. remove_all_actions()
    13. remove_all_filters()
    
  3. AJAX
  4. Cron Job
  5. Internationalization
  6. ShorCode
  7. Custom Post Type
  8. Taxonomies

WordPress Theme Development

The best resource for learning about WordPress theme development is Introduction to Theme Development by WordPress. WebAppick provides and prefer developers to learn about WordPress plugin development from a tutorial by Hasin Hayder. Here is the link ওয়ার্ডপ্রেস থিম ডেভেলপমেন্ট.

Credentials:

username: 
password:

If these credentials are not working please ask for credentials to who are concern.

WordPress Rest API Development

The best resource for learning about WordPress Rest API development is REST API Handbook by WordPress. WebAppick prefer developers to learn about WordPress Rest API development from a tutorial by Tarek Hasan. Here is the link Introduction to REST API in WordPress.

Warning

This tutorial is not beginner friendly. First read and practice about Rest API from documentation by WordPress mentioned above. Then try to view this tutorial by Tarek Hasan

Unit Testing With MACOS

Project Setup

We'll configure codeception for wpunit testing. Below step by step shown how to set up project.

  1. Add require-dev composer packages to composer.json file
    "codeatcode/codeatcs": "^1.0",
    "codeception/codeception": "^4.2",
    "codeception/module-asserts": "^1.0",
    "codeception/module-cli": "^1.0",
    "codeception/module-db": "^1.0",
    "codeception/module-filesystem": "^1.0",
    "codeception/module-phpbrowser": "^1.0",
    "codeception/module-rest": "^1.2",
    "codeception/module-webdriver": "^1.0",
    "codeception/util-universalframework": "^1.0",
    "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
    "ergebnis/composer-normalize": "^2.6",
    "lucatume/function-mocker": "~1.0",
    "lucatume/wp-browser": "^3.1",
    "phpro/grumphp": "^1.13",
    "phpunit/phpunit": "^9.2",
    "szepeviktor/phpstan-wordpress": "^1.1.2",
    "php-webdriver/webdriver": "^1.12"
    
2. Set up the `codeception.dist.yml` file
3. Set up `.env` file. fill params of `env` file constants

WP_ROOT=/Applications/MAMP/htdocs/ctxfeedpro WP_URL='http://localhost:8888/ctxfeedpro' WP_URL_S='http://localhost:8888/ctxfeedpro' WP_DOMAIN='localhost:8888/ctxfeedpro' DB_HOST='localhost' DB_NAME='wordpress64' TEST_DB_NAME='wordpress64' DB_USER='root' DB_PASSWORD='root' DISABLE_ESLINT_PLUGIN=true EXTEND_ESLINT=true 4. PC Set up Required PHP version 7.4. MacOS usually useshomebrewPHP. We have to useMAMP Pro`` PHP for wpunit test. Here is the process to do it run the command in your terminal sudo nano ~/.bash_profile it will open your bash_profile file. Add the following to the file

export PATH="/Applications/MAMP/bin/php/php7.4.21/bin:$PATH"
export PATH=$PATH:/Applications/MAMP/Library/bin

Here first line tels which php version will be used during unit testing. Second tels the path of MySQL After the setting php and mysql to bash_profile now run command source ~/bash_profile. Now all setup is done. 5. Start Unit Test Write test case and start testing by this command.

php ./vendor/bin/codecept run tests/wpunit/Common/DropdropOptionTest.php —debug

Resource to study

  1. How to override the path of PHP to use the MAMP path?
  2. How to add MySQL to $PATH variable to resolve "mysql: command not found"?
Make alias in Mac
alias codecept="php ./vendor/bin/codecept run"

PHPSTAN TEST
 php ./vendor/bin/phpstan analyse libs/webappick-product-feed-for-woocommerce/V5/Common/Helper.php

PHPCS TEST
php ./vendor/bin/phpcs libs/webappick-product-feed-for-woocommerce/V5/Common/Helper.php  

CODECEPT TEST
php ./vendor/bin/codecept run tests/wpunit/Common/DropdropOptionTest.php —debug

React Tutorials

GrumPHP

Sick and tired of defending code quality over and over again? GrumPHP will do it for you! This composer plugin will register some git hooks in your package repository. When somebody commits changes, GrumPHP will run some tests on the committed code. If the tests fail, you won't be able to commit your changes. This handy tool will not only improve your codebase, it will also teach your co-workers to write better code following the best practices you've determined as a team.

GrumPHP has a set of common tasks built-in. You will be able to use GrumPHP with a minimum of configuration.

Installation & Documentation

Use specific php in Mac

First Run The Command.

THEN RUN THIS COMMAND

export export MAMP_PHP=/Applications/MAMP/bin/php/php7.4.21/bin
export PATH=“$MAMP_PHP:$PATH”

For Editing bash_profile file

Sodu nano ~/.bash_profile

Add these 2 line in bash_profile file

export PATH="/Applications/MAMP/bin/php/php7.4.21/bin:$PATH"
export PATH=$PATH:/Applications/MAMP/Library/bin

Then run this command

source ~/.bash_profile

Unit Testing With MACOS

For Unit Testing we will use codeception. Codeception is a modern full-stack testing framework for PHP. Inspired by BDD, it provides an absolutely new way of writing acceptance, functional and even unit tests. Powered by PHPUnit.

  • Run this command for testing a file
php ./vendor/bin/codecept run tests/wpunit/Common/DropdropOptionTest.php --debug
  • Run this command for testing a file with specific test case
php vendor/bin/codecept run tests/wpunit/Product/ProductInfoTest.php:test_title --debug

PHPSTAN TEST

php ./vendor/bin/phpstan  analyse --standard=CodeatCodingStandard libs/webappick-product-feed-for-woocommerce/V5/Common/Helper.php

PHPCS TEST

php ./vendor/bin/phpcs --standard=CodeatCodingStandard libs/webappick-product-feed-for-woocommerce/V5/Common/Helper.php

How to override the path of PHP to use the MAMP path?

How to add MySQL to $PATH variable to resolve "mysql: command not found"?

https://stackoverflow.com/questions/4145667/how-to-override-the-path-of-php-to-use-the-mamp-path

Make alias in Mac

alias codecept="php ./vendor/bin/codecept run "
alias phpcs='php ./vendor/bin/phpcs --standard=CodeatCodingStandard'
alias phpcbf='php ./vendor/bin/phpcbf --standard=CodeatCodingStandard'
export PATH="/Applications/MAMP/bin/php/php7.4.21/bin:$PATH"
export PATH=$PATH:/Applications/MAMP/Library/bin

Edit .bashrc file in home directory

sudo nano ~/.bashrc
alias codecept="php ./vendor/bin/codecept run "
alias phpcs='php ./vendor/bin/phpcs --standard=CodeatCodingStandard'
alias phpcbf='php ./vendor/bin/phpcbf --standard=CodeatCodingStandard'
export PATH="/Applications/MAMP/bin/php/php7.4.21/bin:$PATH"
export PATH=$PATH:/Applications/MAMP/Library/bin
alias grumphp=" php ./vendor/bin/grumphp run"

NVM USE IN MAC

source $(brew --prefix nvm)/nvm.sh
nvm use 14.15.0

How to manage multiple GitHub accounts on a single machine with SSH keys

https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/ FOR SWITCHING ACCOUNT

$ ssh-add -D
$ ssh-add ~/.ssh/id_azizulhasan

$ ssh-add -D
$ ssh-add ~/.ssh/id_ed25519

Change username and email

Git config user.name “azizulhasan”
Git config user.email “[email protected]

Path /Applications/MAMP/htdocs/wordpress-develop

Docker Error Bind: Address Already in Use

https://www.baeldung.com/linux/docker-address-already-in-use

lsof -i:8080 ( port )

source ~/.bash_profile

Reset if there is a problem with running

"env:start": "node ./tools/local-env/scripts/start.js",
"env:stop": "node ./tools/local-env/scripts/docker.js down",
"env:restart": "npm run env:stop && npm run env:start",
"env:clean": "node ./tools/local-env/scripts/docker.js down -v --remove-orphans",
"env:reset": "node ./tools/local-env/scripts/docker.js down --rmi all -v --remove-orphans"

WordPress Coding Standards

https://wp-punk.com/wordpress-coding-standards-for-php/ https://packagist.org/packages/wp-coding-standards/wpcs

developer-manual's People

Contributors

webappick avatar webappickhasan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.