Posts

Showing posts from October, 2022

The most common HTTP Status codes

As we write API calls, we've also added t he status codes  to our endpoint response.  This lets us explicitly return JSON data and send an  HTTP  code the client can parse.  The most common codes you’ll be returning will be: 200: OK. The standard success code and default option. 201: Created. Object created. Useful for the store actions. 204: No Content. When the action was executed successfully, there is no content to return. 206: Partial Content. Useful when you have to return a paginated list of resources. 400: Bad Request. The standard option for requests that cannot pass validation. 401: Unauthorized. The user needs to be authenticated. 403: Forbidden. The user is authenticated but does not have permission to perform an action. 404: Not Found. Laravel will return automatically when the resource is not found. 500: Internal Server Error. Ideally, you will not be explicitly returning this, but if something unexpected breaks, this is what your use...

How to Install Multiple PHP(7.3 and 8) Versions on Ubuntu > 20

Image
 Step 1: System Update First, log in to Ubuntu via console. Then update the Apt cache and upgrade the current packages of the system using the following command: sudo apt-get update sudo apt-get upgrade  When prompted, press y to confirm the installation. Step 2: Installing Multiple PHP Versions on Ubuntu > 20 The easiest way to install multiple versions of PHP is by using the PPA from Ondřej Surý, who is a Debian developer. To add this PPA, run the following commands in the terminal. The software-properties-common package is needed if you want to install software from PPA. It’s installed automatically on the Ubuntu desktop but might miss on your Ubuntu server. sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update The SURY repository contains PHP 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0 & PHP 5.6. As the latest stable version of PHP is 8.0, but many websites still required PHP 7. You can install any of the required PHP versions on y...

Run Composer versions 1 and 2 simultaneously

Composer 2 is great. But it is not compatible with PHP versions lesser than 7.2. So if you're maintaining legacy projects that require older PHP versions, like PHP 7.1, you run into errors like this: PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.2.0". You are running 7.1.33. If you want to be able to run Composer 1 and 2 next to each other, you can install them both. Install Composer globally, following the instructions from https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos .  This will install the latest Composer 2 version in /usr/local/bin . (on Mac you can simply run brew install composer ) Move composer to composer2: mv /usr/local/bin/composer /usr/local/bin/composer2 CD to the /usr/local/bin/ folder: /usr/local/bin/ Download the latest V1 version from https://getcomposer.org/download/1.10.17/composer.phar : wget https://getcomposer.org/download/1.10.17/composer.phar Make the...