Do not use .env to store sensitive credentials in Laravel

If you are working in Laravel, you might have noticed that majority of the developers save sensitive information like database credentials, SMTP settings and API keys in the .env file. This file exists at the root level of your project. I was also saving my credentials in .env files for a long time until I …

Get file extension from name – Javascript, PHP

Getting file extension from file name or path can be done in Javascript and PHP. I will show you the steps to get the file extension and you can apply them in any language you want. Following code will get the file extension from file name or file path in Javascript: Your parts variable will …

Highlight current tab after page refresh – HTML, Javascript, PHP

bootstrap-tabs

Suppose you are creating a tab layout where there are multiple tabs and each tab has its own content. You click on the tab button and its content is displayed. But when you refresh the page, it starts from the first tab again. How can you make so that when you refresh the page, it …

Get auth user without sanctum middleware – Laravel

In order to get an authentication user without using sanctum middleware in Laravel, you just need to pass the string “sanctum” in auth() method. Auth sanctum without middleware Following route goes in the “routes/api.php” file: Auth sanctum with middleware If you do not want to use the “sanctum” string in auth() method, then you need …

File Manager in Laravel and React JS

File manager in Laravel and React JS

A file manager web app is created in Laravel and React JS. We offer free 10 MB storage so you can test this script. Test it before you buy it. Easy deployment, you can just buy and upload the files on your server. Further instructions for deployment are in the file “README.md”. Check our tutorial …

How to compress image in PHP

compress-image-php

Previously, I wrote an article on how to compress images in Node JS. In this article, we will discuss how you can compress an image in PHP. Let’s say you have an image named “image.png”. The following code will compress the file by half: Explanation: Why use JPEG for compressed image You might be wondering …

How to fix Laravel 403 forbidden storage error

How to fix Laravel 403 forbidden storage error

If you keep getting 403 forbidden error on your Laravel storage files and you want to know how to fix this, you have landed on the right site. 403 forbidden error is typically when you do not have enough permission to read a file and it happens mostly on live servers (on production). I was …

Get uploaded file size in Laravel 11

If you are working in Laravel and want to get the size of uploaded file, you have come to the right place. Let’s say you are developing an application where it is required to see the total file size uploaded by user. In this case, you need to keep track of all the uploaded files. …