Posts

Understanding REST API Response Status Codes

When building or consuming RESTful APIs, understanding HTTP response status codes is essential. These codes tell the client whether a request was successful, failed, or needs additional action. In this guide, we break down the most commonly used status codes in REST APIs with simple explanations and real-world usage examples. ⭐ What Are HTTP Status Codes? HTTP status codes are standardized responses sent by a server when processing an API request. They are grouped into five categories: 1xx – Informational 2xx – Successful 3xx – Redirection 4xx – Client Errors 5xx – Server Errors For REST APIs, the 2xx , 4xx , and 5xx groups are most important. ✅ 1. Success Status Codes (2xx) These indicate that the request was successfully received and processed. 200 OK The most common success response. Used when a request is successful and returns data. Example: Returning a list of products from /api/products . 201 Created Used when a new resource is created suc...

What is Docker?

  What is Docker? From Shipping Containers to Software Containers Docker is a revolutionary technology that has completely changed the way software is developed, shipped, and deployed. If you want to become a DevOps engineer or stay relevant in modern software engineering, learning Docker is essential. But what exactly is Docker, and why is it called “Docker”? To understand that, we need to take a quick journey back into the history of the shipping industry. Before the Shipping Container Revolution The Chaos Before the 1950s Before the 1950s, loading and unloading cargo from ships was extremely slow, difficult, and expensive. Ships carried goods in: Wooden boxes Barrels Sacks Nets and odd-shaped bags Everything had different shapes and sizes, so: Hundreds of workers were needed to load/unload The cargo often got damaged Ships wasted a lot of space The process was slow and inefficient Major Problems Slow loading/unloading Expensive due...

Previewing My Laravel Localhost on Mobile Devices

As a developer, I often need to check how my projects look and perform on mobile devices, especially for responsive testing. However, localhost typically works only on the same PC. Here’s the simple process I use to preview my Laravel project on a mobile device connected to the same Wi-Fi network: Step 1 — Find Your PC’s IP Address For Windows: Open Command Prompt . Type: ipconfig Note your IPv4 Address (for example: 192.168.0.107 ). For Ubuntu/Linux: Open Terminal . Type the following commands: nmcli dev status nmcli dev show wlp2s0 Find your IP4.ADDRESS value (for example: 192.168.0.107 ). Step 2 — Run Laravel Server for All Devices Navigate to your Laravel project folder. Run the command: php artisan serve --host= 0.0.0.0 --port= 8000 This command allows any device on the same network to access your local server. Step 3 — Access from Your Mobile Browser Ensure your phone and PC are connected to the same Wi-Fi network . On your mobile browse...

Input type date default placehoder change

<input id="my_date"  name="my_date"  class="form-control"  placeholder="My Date"  type="text"  onfocus="(this.type='date')"  onblur="(this.type='text')">

CK Editor

< script src ="https://cdn.ckeditor.com/4.5.7/standard/ckeditor.js" ></ script > < script type ="text/javascript" > $ ( function () { // Replace the <textarea id="editor1"> with a CKEditor // instance, using default configuration. CKEDITOR. replace ( 'description' , { // toolbar: [ // { name: 'document', items: ['Source', '-', 'NewPage', 'Preview', '-', 'Templates' ] }, // Defines toolbar group with name (used to create voice label) and items in 3 subgroups. // [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo', 'Undo', 'Redo' , 'Undo', 'Redo', 'Undo', 'Redo', 'Undo'], // Defines toolbar group without name. // '/', ...

HTTPS Setup With Certbot in Digital Ocean Droplets

For Installation sudo apt install python3-certbot-apache For Activation sudo certbot --apache --expand -d domainname.com

Plain php text showing issue solve

Solution: 1 sudo systemctl status php8.1-fpm sudo apt-get install php8.1-fpm sudo apt install apache2 libapache2-mod-fcgid sudo apt install libapache2-mod-fcgid sudo a2enmod actions fcgid alias proxy_fcgi Solution: 2 sudo a2dismod mpm_event sudo systemctl restart apache2 sudo a2enmod mpm_prefork sudo systemctl restart apache2 sudo a2enmod php7.0 sudo systemctl restart apache2

Unblock the block port in ubntu

sudo lsof -t -i:8000 This command will return a process ID sudo kill -9 565934  

Laravel application's error logs & access tracking individually

Add two lines bottom of the Virtual Host tag. <VirtualHost *:80>     ErrorLog ${APACHE_LOG_DIR}/error_application.log     CustomLog ${APACHE_LOG_DIR}/access_application.log common </VirtualHost> This command is for showing the logs (-n 100 means the last 100 logs) tail -n 100 access_application.log

Fixed: Requested URL Was Not Found on this Server Apache2 Ubuntu

When you install Apache2 on a Linux server. At that time mod_Rewrite module is not enabled by default on apache 2. And of which website or app you run on the server, and you open any url of this, then you see the message “the requested url was not found on this server apache2 ubuntu”. So in the tutorial “the requested url was not found on this server apache2 ubuntu” you will learn how to enable rewrite_module and solve this error. The apache Mod_rewrite is very popular for rewriting human-readable URLs in dynamic websites. This makes the URL’s look cleaner and SEO-friendly on websites. In this tutorial, we will show you how to enable the apache/2.4.5 ubuntu mod_rewrite module and configure it for use .htaccess files available with apache 2 ubuntu web server at port 443, 80. Step 1 – Update dependencies sudo apt-get update If you want to enable mod_rewrite apache in ubuntu. So, you can connect your instance or web server to ssh terminal. And then type a2enmod command to enable any modul...

root .htaccess file when laravel project upload in cpanel

 <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] </IfModule>

Understanding file permissions

Image
This string of letters, drwxrwxrwx , represents the permissions that are set for the directory. Each number can have one of eight values ranging from 0 to 7 . Each value corresponds to a certain setting of the read, write and execute permissions, as explained in the following table. For Example: 777 is the same as rwxrwxrwx 755 is the same as rwxr-xr-x 666 is the same as rw-rw-rw- 744 is the same as rwxr--r--

Deploy laravel application to digital ocean droplet

ssh root@192.168.0.1 adduser coderstation usermod -aG sudo coderstation su - coderstation sudo apt-get install apache2 sudo apt-get install php sudo apt-get install git sudo apt-get install composer sudo apt install mysql-server sudo mysql mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; mysql> exit mysql -u root -p mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket; sudo mysql_secure_installation mysql>CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password'; mysql>ALTER USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; mysql>GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'localhost' WITH GRANT OPTION; mysql>FLUSH PRIVILEGES; mysql> exit cd /var/www/htm git clone project cd project sudo apt-get install php-xml sudo apt-get install...

File/Folder Upload/Download From/To Local/Remote

 copy from remote to local scp file.txt remote_username@10.10.0.2:/remote/directory scp folder from server to local scp -r user@your.server.example.com:/path/to/foo /home/user/Desktop/ how to copy directory to a ssh server # Copy from machine a to b scp -r /path/to/directory user@ipaddress:/path/to/destination # Copy from machine b to a scp -r user@ipaddress:/path/to/destination /path/to/directory copy folder from ssh to local scp -r user@your.server.example.com:/path/to/foo / ssh copy folder from local to remote scp -ra /path/to/local/storage user@remote.host:/path/to/copy ssh copy folder from local to remote scp /path/of/your/local/filename username@hostname:/path/to/remote/server/folder

Server setup basic guide

 BASIC GUIDE ssh root@192.168.0.1 -p 22 adduser hasib ssh -l hasib 192.168.0.1 Update OS Install Apache Install MySQL Install PHP Install Composer (Composer install and globalization) sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin –filename=composer Install Git Set DNS Server Name to Domain Name Provider Panel

Git post receive setup at server for git push to the production from local machine

IN SERVER cd www mkdir repo cd repo mkdir app.website.git cd app.website.git git init –bare cd hooks touch post-receive chmod R 775 post-receive put the following line in post-receive file git --work-tree=/var/www/html/app.website.com --git-dir=/var/www/repo/app.website.git checkout master -f cd /var/www/html/app.website.com nano /etc/hosts 127.0.1.1 app.website.com cd /etc /apach2 /site-available cp 000-deault.conf app.website.com.conf LOCALLY git remote -v git remote add prod-website ssh://root@192.168.0.1:/var/www/repo/app.website.git

Way to get fillable fields from a specific table

SELECT CONCAT("'",COLUMN_NAME,"',") FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'undp_liupcp_survey' ORDER BY ORDINAL_POSITION ASC; 

Change the default PHP version from multiple PHP version (Version 7.0 to Version 7.1)

Disable the current php version $ sudo a2dismod php7.0 Restart the apache $ sudo systemctl restart apache2 Enable the expect php version $ sudo a2enmod php7.1 ** If problem arise then the following two line $ sudo apt purge libapache2-mod-php7.1 libapache2-mod-php $ sudo apt install libapache2-mod-php7.1 libapache2-mod-php Enable the expect php version $ sudo a2enmod php7.1 Restart the apache $ sudo systemctl restart apache2 Check the php version $ php -v Finally set the php version $ sudo update-alternatives --set php /usr/bin/php7.1 Check the php version $ php -v Restart the apache2 $ sudo systemctl restart apache2

MySQL database dump from terminal command

Basic dump command :  mysqldump -u root -p prod_helpdesk > db_backup.sql Dump command with rename file by date time :  mysqldump -u root -p prod_helpdesk > prefix_$(date +%Y-%m-%d-%H.%M.%S).sql

SQL query with multiple database and different tables in Laravel

DB::select("SELECT db1.employees.name AS employee_name, db2.companies.name as company_name FROM db1.employees employees JOIN db2.companies companies ON companies.code = employees.company_code WHERE companies.country = 'Bangladesh' "); Note: Both database users and passwords have to be the same.