Categories
API General Web API

How to improve an API speed performance ?

Today’s challenge : investigate the slow responsiveness of the api. I was assigned the task to investigate the performance report produced the day before. The report concluded in the most unclear manner that the backend was lacking in term of performance. No precision regarding the list of failing api calls was provided. I used newRelic and discovered that indeed during the specific timeframe mentioned a clear bottleneck was surfacing an a specific api call to a specific internal server.

I reached out to the developer mainly responsible of this server. The newRelic information [pointing out the entanglement] was challenged in the most defensive and almost aggressive manner to my stupefaction.

Developer do not like to be pointed out or criticized. What/How should have approach this developer ?=

The developer challenged the results by saying “I just executed the specified api endpoint with the specified payload and guess what; the result came back under one second”. Omitting the context of Heavy Test Performance. So being pushed back multiple time, I moved on to the sysOp department to get more information on what was going on.

The slow server obviously was not monitored with newRelic. A coordination with sysOp was necessary to get this server under surveillance. During our meeting, it was established that the server was under provisioned in term of CPU power and memory space. We did increase these metrics.

The tests were ran and passed successfully. The main challenges were to get the approval from the CIO to have sysOp moving and the developer’s resistance to acknowledge a possible glitch on the server.

My approach toward this developer although very specific and data documented should have been persuasive rather than convincing.

Categories
API Web API

RESTFUL API – HTTP CODE 422 – Unprocessable Entity

The HyperText Transfer Protocol (HTTP) 422 Unprocessable Entity response status code indicates that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.

Categories
Access Token API Laravel Oauth PHP Valet Web API

Laravel Passsport – Oauth2

Laravel makes API authentication a breeze using Laravel Passport, which provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. Passport is built on top of the League OAuth2 server that is maintained by Andy Millington and Simon Hamp.

Categories
Continuous Integration/Development Programming Web API

How to step by step implement Continuous Integration and Continuous Development in your software team ?

Fast development and Integration according to David Raleche – Process

 

 

 

QA

  • Introducing new bugs after making a change (No proper regression test)
  • Increase Automation overall
  • Lack of transparency
  • Improve quality and testability
  • No Proper Api documentation (Swagger)

Developers

  • Duplicate code throughout the program
  • Reading or writing code which is difficult to understand (PSR-2)
  • No Peer Programming (Code Review) in place (Pull Request)

 

  • CLEAN CODE

 

  • DRY do not repeat yourself
  • KISS – Keep it Stupid Simple
  • PSR-2 Code Styling
  • PSR-3 Log for debug purposes
  • PSR-4 Comment Code Properly
  • Function no exceeding 40 lines

 

  • No ERRORS

 

  • PHP Code
    • No Errors
    • No Warnings
    • No Notices
  • Unit Testing – 2 per api calls

 

  • CREATE Functional API Test

 

    • 3 positive tests
    • 3 negatives

 

 

  • Final API Documentation (swagger)

 

 

  • Check PHP logs (Nagios)
    • PHP Code
      • No Errors
      • No Warnings
      • No Notices

 

  • Execute Regression Testing

  • Make sure unit testing reach out full Code coverage
Categories
BEST PHP CODE Web API

Convert to utf-8 values of an (multi-dimensional) associative array

/**
 * Convert to utf-8 values of an (multi-dimensional) array
 *
 * @param $array
 *
 * @return $array
 */
public function utf8Converter($array)
{
    array_walk_recursive($array, function (&$item, $key) {
        $item = utf8_encode($item);
    });

    return $array;
}
Categories
Nginx Web API

CORS ISSUE NGINX SWAGGER FETCH ERROR SOLUTION – Jeeezzz !

CORS Solution for NGINX SWAGGER

set $origin $http_origin; 

if ($origin !~ '^https?://(docs-mapi)\.4over\.com) {
 set $origin 'https://yourdomain.com';
 }

add_header 'Access-Control-Allow-Origin' "$origin" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, PATCH, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Access Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, api_key' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
Categories
Web API

give information regarding yum installed packages

sudo repoquery –list php72-php-pecl-xdebug.x86_64

/etc/opt/remi/php72/php.d/15-xdebug.ini
/opt/remi/php72/root/usr/bin/debugclient
/opt/remi/php72/root/usr/lib64/php/modules/xdebug.so
/opt/remi/php72/root/usr/share/doc/pecl/xdebug
/opt/remi/php72/root/usr/share/doc/pecl/xdebug/CREDITS
/opt/remi/php72/root/usr/share/doc/pecl/xdebug/LICENSE
/opt/remi/php72/root/usr/share/doc/pecl/xdebug/README.rst
/opt/remi/php72/root/usr/share/doc/pecl/xdebug/contrib
/opt/remi/php72/root/usr/share/doc/pecl/xdebug/contrib/tracefile-analyser.php
/opt/remi/php72/root/usr/share/doc/pecl/xdebug/contrib/xt.vim
/opt/remi/php72/root/usr/share/doc/pecl/xdebug/xdebug.ini
/var/opt/remi/php72/lib/pear/pkgxml/php72-php-pecl-xdebug.xml

Categories
Web API

Mysql Tables sizes

select table_schema, sum((data_length+index_length)/1024/1024) AS MB from information_schema.tables group by 1;
Categories
BEST PHP CODE Web API

Git Force pull

I think this is the right way:

git fetch --all

Then, you have two options:

git reset --hard origin/master

OR If you are on some other branch:

git reset --hard origin/<branch_name>
Categories
Web API

help install code sniffer

C:\xampp\php\php.exe composer.phar require “squizlabs/php_codesniffer=*”