Categories
General

How to fix “Error: [email protected] has been disabled because it is a versioned formula!” on mac ?

#1 brew tap


#2 brew tap shivammathur/php

#3 brew install shivammathur/php/[email protected]\n

#4 phpbrew install 8.0

#5 brew install [email protected]\n

#6 brew reinstall [email protected]

Categories
General

How to solve fourover/sdk v0.2.2 requires ext-yaml * -> it is missing from your system. Install or enable PHP’s yaml extension. ??

fourover/sdk v0.2.2 requires ext-yaml * -> it is missing from your system. Install or enable PHP’s yaml extension.1

JUST DO

pecl install yaml

  1. ↩︎
Categories
General

How to shutdown/close ports on MAC ?

How to address this error on MAC ?

Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:443 -> 0.0.0.0:0: listen tcp 0.0.0.0:443: bind: address already in use

Listen to port 80 or 443

sudo lsof -i :80 
sudo lsof -i :443 

in my case nginx was up and running so

sudo nginx -s stop

MOST IMPORTANT

STOP ALL your docker instances !!!!

Categories
General

How to shutdown nginx on MAC OS X ?

To shut down Nginx on macOS, you can use the following commands in your terminal. Please note that you might need administrative privileges (sudo) to stop Nginx, depending on how it was installed.

  1. Open Terminal: You can find Terminal in the Utilities folder within the Applications folder, or you can use Spotlight Search (Cmd + Space, then type “Terminal”).
  2. Check if Nginx is running:perlCopy code
    ps aux | grep nginx
    This command will list any Nginx processes that are currently running. If you see any processes related to Nginx, note the process IDs (PIDs) as you’ll need them to stop Nginx.
  3. Stop Nginx using the PID(s):bashCopy code
    sudo kill -s QUIT <PID>
    Replace <PID> with the actual process ID of Nginx that you want to stop. If there are multiple Nginx processes, you’ll need to run the sudo kill -s QUIT command for each of them.
Categories
General

How to solve “No releases available for package pecl.php.net/libyaml” ?

How to solve ?

pecl install libyaml
No releases available for package "pecl.php.net/libyaml"
install failed

Try the following ?

pear clear-cache
pear update-channels
pear upgrade

try this command instead

pecl install yaml

Categories
General

Checklist / Code Review PHP

Checklist

ELEGANT CODING/ PROGRAMMING appreciated

Utilize the guard clause writing style instead of the traditional if-else approach.

Use Guard Clauses for Cleaner Code

There should be no business logic in the controller (Sanity check okay)

There should be no database code in the service or controller classes

Solid principles: Ensure that the code follows the SOLID principles of object-oriented design, which include Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion principles. These principles promote clean, maintainable, and extensible code.

Type hinting: Use type hints in function and method declarations to specify the expected data types for parameters and return values. Type hinting helps improve code clarity and prevents type-related errors.

TRY CATCH: Implement proper error handling using try-catch blocks. This ensures that exceptions are caught and handled gracefully, preventing crashes and providing meaningful error messages to users or developers.

Properly log exceptions: Log exceptions in a structured and informative way, including the date and time of the exception occurrence, the type of exception, the exception message, the file where it occurred, and the line number. This helps in debugging and tracking issues efficiently.

} catch (Exception $e) { // Log the exception message, filename, and line number $logMessage = "Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; $logMessage .= $e->getTraceAsString(); HelperService::logger('debug',logMessage); // Rethrow the exception if necessary throw $e; }

Example log format: [Date and Time] – [Exception Type]: [Exception Message] in [File] on line [Line Number]

declare(strict_types=1);

Declare strict_types = 1;: Enable strict typing in PHP by declaring strict_types = 1; at the beginning of your PHP scripts. This ensures that type coercion is disabled and helps prevent unexpected type-related issues.

Functional tests: Develop and perform functional tests for your code to verify that it behaves as expected and meets the specified requirements. Functional tests help ensure the correctness of your code.

PHP Doc: Use PHPDoc comments to provide clear and comprehensive documentation for your code. Include descriptions of functions, methods, classes, and their parameters, return types, and any exceptions they may throw. Well-documented code is easier for others to understand and use.

Validate PSR-2 compliance: Ensure that your code adheres to the PSR-2 coding style standard for PHP. PSR-2 provides guidelines for code formatting, naming conventions, and indentation, promoting consistency and readability across projects.

No PHP error messages: Make sure that there are no PHP error messages in your code. PHP errors can disrupt the functionality of your application and should be addressed and resolved.

No PHP Warning messages: Similarly, ensure that there are no PHP warning messages in your code. Warnings can indicate potential issues that need to be fixed to maintain the stability of your application.

No PHP Notices: Eliminate PHP notices from your code. Notices are typically non-fatal issues, but it’s best to address them to prevent unexpected behavior.

No hardcore credentials: Avoid hardcoding sensitive credentials such as usernames, passwords, or API keys directly into your code. Instead, use secure configuration management practices to store and access these credentials securely. Use feature toggle

Function no longer than 50 lines: Keep individual functions or methods concise and focused, with a maximum of 50 lines of code. This promotes code readability and maintainability by breaking complex logic into smaller, more manageable pieces.

Coding Principles

2 – PHP Docs should mach the following format

/** * Update Shipment Status * * @param string $m2_shipment_uuid * @param string $payload * @return bool * * @throws Exception * Exception('No file requirements',500) * Exception('issue converting artworkinfo into an object',500) * Exception('Artwork info not available for set_uuid :'.$shipment['m2_set_uuid'], 422); * Exception('file_uuid is not present within the artwork info block of set_uuid :'.$shipment['m2_set_uuid'], 422) * * @author David Raleche <[email protected]> * * @since 10-09-2020 * @version 10-28-2020 * * @internal M2-1045 Extend PATCH /v1/m2-shipments/:uuid to validate that files are still available */

@Raman Sobal @Manit Shah @Salvi Pascual @Nurbek Chymbaev

@Kevin Fung@v-johnlee (Unlicensed) add an equivalent in Javascript below

GIT Conflict Steps to FOLLOW

#1 – step – Squash Merge

#2 – in case of Pull Request conflict against DEV environment

(1) clone your branch and rename yourbranch_merge_to_dev_03-22-2022

(2) do a pull request of that branch against DEV

(3) Resolve conflict via UI or via your sandbox

When resolving conflict via sandbox, follow the steps below :

Step 1. git merge dev --no-commit --no-ff

This will bring in changes from dev without merging them

Step 2. Examine the result of step 1 and find the conflict files and fix them locally

Step 3. git commit -am "conflict resolved"

Step 4. git push origin yourbranch_merge_to_dev_03-22-2022

Above steps will avoid bringing in Dev branch changes into your pull request

(4) Squash Merge

#3 – in case of Pull Request conflict against QA environment

(1) clone your branch and rename yourbranch_merge_to_qa_03-22-2022

(2) do a pull request of that branch against QA

(4) Squash Merge

(3) Resolve conflict via UI or via your sandbox

Categories
General

How to resolve git merge – – not something we can merge ?

If you try something

git merge feature/the-feature-branch-XXX

and you see


merge: feature/the-feature-branch-XXX - not something we can merge

SOLUTION in 2 steps

step 1 : git checkout –track origin/feature/the-feature-branch-XXX

step 2 git checkout release/target_branch

step 3 (try again) : git mergefeature/the-feature-branch-XXX

Categories
General

PHP MANDATORY CODE REVIEW Checklist

  1. Solid principles: Ensure that the code follows the SOLID principles of object-oriented design, which include Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion principles. These principles promote clean, maintainable, and extensible code.
  2. Type hinting: Use type hints in function and method declarations to specify the expected data types for parameters and return values. Type hinting helps improve code clarity and prevents type-related errors.
  3. TRY CATCH: Implement proper error handling using try-catch blocks. This ensures that exceptions are caught and handled gracefully, preventing crashes and providing meaningful error messages to users or developers.

try { // Code that may throw exceptions } catch (ExceptionType1 $e1) { // Handle ExceptionType1 } catch (ExceptionType2 $e2) { // Handle ExceptionType2 } catch (ExceptionType3 $e3) { // Handle ExceptionType3 }

  1. Properly log exceptions: Log exceptions in a structured and informative way, including the date and time of the exception occurrence, the type of exception, the exception message, the file where it occurred, and the line number. This helps in debugging and tracking issues efficiently.Example log format: [Date and Time] – [Exception Type]: [Exception Message] in [File] on line [Line Number]
  2. Declare strict_types = 1;: Enable strict typing in PHP by declaring strict_types = 1; at the beginning of your PHP scripts. This ensures that type coercion is disabled and helps prevent unexpected type-related issues.
  3. Functional tests: Develop and perform functional tests for your code to verify that it behaves as expected and meets the specified requirements. Functional tests help ensure the correctness of your code.
  4. PHP Doc: Use PHPDoc comments to provide clear and comprehensive documentation for your code. Include descriptions of functions, methods, classes, and their parameters, return types, and any exceptions they may throw. Well-documented code is easier for others to understand and use.
  5. Validate PSR-2 compliance: Ensure that your code adheres to the PSR-2 coding style standard for PHP. PSR-2 provides guidelines for code formatting, naming conventions, and indentation, promoting consistency and readability across projects.
  6. No PHP error messages: Make sure that there are no PHP error messages in your code. PHP errors can disrupt the functionality of your application and should be addressed and resolved.
  7. No PHP Warning messages: Similarly, ensure that there are no PHP warning messages in your code. Warnings can indicate potential issues that need to be fixed to maintain the stability of your application.
  8. No PHP Notices: Eliminate PHP notices from your code. Notices are typically non-fatal issues, but it’s best to address them to prevent unexpected behavior.
  9. No hardcore credentials: Avoid hardcoding sensitive credentials such as usernames, passwords, or API keys directly into your code. Instead, use secure configuration management practices to store and access these credentials securely.
  10. Function no longer than 50 lines: Keep individual functions or methods concise and focused, with a maximum of 50 lines of code. This promotes code readability and maintainability by breaking complex logic into smaller, more manageable pieces.
Categories
General

warden magento : How to fix Port must be configured within host parameter (like localhost:3306 ?

php bin/magento cache:clean

In Mysql.php line 407:

Port must be configured within host parameter (like localhost:3306

make sure you do the commands within

warden shell

Categories
General

HOW TO IMPORT DUMP DATABASE FILE INTO WARDEN ?

pv ../../NEW-CLEANED-DUMP.sql | warden db import

Importing a dump database file into a database involves using command-line tools specific to the database management system, such as MySQL or PostgreSQL, and executing the appropriate commands to load the data from the dump file into the database. The process requires providing the necessary credentials, specifying the database name, and waiting for the import process to complete.