Categories
BEST PHP CODE

Best PHP comment !

Hello developers,

Here is my typical php comment/header for each of my php functions. Very useful and pragmatic. They provide a clear indication what the function is doing, inputs, outputs and exceptions. This is the art of coding ! Clear readibility and full transparency on the intentions of the functions.

I would definitely make this a requirement for programmer team. Additional work but useful. And if it is an API I would use the zircote/swagger-php library to generate on the fly an amazing swagger documentation

/**
 * Throw Exception If Parameter Is Not Set
 *
 * @param object $requestObjectBody
 * @param int $httpCode
 * @param string $httpMessage
 *
 * @return void
 *
 * @throws \Exception $exception
 *
 * @author  David Raleche <[email protected]>
 * @since 10-09-2020
 * @version 10-09-2020
 * @internal <ticket-number>
 */
public static function throwExceptionIfParameterNotSet($param, int $httpCode, string $httpMessage)
{
    if (is_null($param) or empty($param)) {
        throw new \Exception(
            $httpMessage,
            $httpCode
        );
    }
}

CIO/Managers : When having interns in your company the first exercise to give them is to go trhough existing code and add the following blocs of PHP docs. This will help them understand the code and this will improve considerable the readability of the legacy code. By doing so we quickly pinpoint the function to refactor

I usually give them the task to refactor functions being too long. More than 50 lines

David Raleche PHP good practice
David Raleche PHP good practice php developers
Categories
Technical

What is the best practice for naming a REST endpoint ?

Lowercase letters and dashes

By convention, resource names should use exclusively lowercase letters. Similarly, dashes (-) are conventionally used in place of underscores (_).

Example: /users/{id}/pending-orders instead of /users/{id}/Pending_Orders

Source of information

Using a hyphen in your URLs is recommended by Google, because it makes your website easy to read for humans. As an end result, this means that your site will place better on search engines. Are you looking to learn more about how to improve the SEO of your blog?

Categories
General

How to fix wordpress Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /wp-includes/plugin.php on line xxx?

Solution is to add the following line below to this file wp-config.php

define( 'WP_MEMORY_LIMIT', '256M' );
Categories
General

How to access cloud Magento Dasboard ?

Here is the link to access Magento cloud dashboard

https://us-3.magento.cloud/projects

Categories
Satori Architect

How to fix Satori issue 80040421 ?

The problem 80040421 is not always Unable to allocate any sequence numbers

This time the problem was missing permits to execute the presorting of the requests

The solution is to make sure these permits exists and the problem will go away

Also, If you have already done the configuration in the past know that the configuration file exists in the following folder C:/WINDOWS

The file name is mrtk.ini 

Categories
AWS

How to make AWS Snapshot backup ?

The top priority of a developer is to have backups at any point of time.

To have peace of mind I suggest the followingsteps proposed by Amazon AWS when having an EC2 instance

https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/TakeScheduledSnapshot.html

Categories
Technical

How to Make your websites stronger against DDOS ?

I found myself dealing with web server being down, being daily attacked online. My remedy to all of these problems is cloudfare

cloudfare
cloudfare
cloudfare ddos
cloudfare ddos
Categories
Unix

How to start a httpd service when rebooting linux ?

How to make sure your service starts when you server reboot? It is practical so you do not have to ssh into your machine everytime you want to start your web server. Find below the command used for that effect

sudo chkconfig --levels 0123456 httpd on

Here explanation of levels

0   Halt
1   Single-User mode
2   Multi-user mode console logins only (without networking)
3   Multi-User mode, console logins only
4   Not used/User-definable
5   Multi-User mode, with display manager as well as console logins (X11)
6   Reboot

Make it happen – Automate things become a senior software engineer

Categories
General

How to Force/change default homepage of Laravel Nova ?

To Force the redirect of Laravel Nova I proceeded with modifications

#1 – Remove the default route definition

routes/web.php
routes/web.php

#2 – Address the ‘/nova’ path to just ‘/’

config/nova.php
config/nova.php
Categories
Technical

How to check the Health Status of your servers for free ?

It has been on my mind for a long time … How to get notified when one of my web properties go down . I found this amazing free website tool called UPTIME ROBOT – Get notified for free and stay on the top of your business

https://uptimerobot.com/

uptimerobot
uptimerobot moniotor server health