Tuesday, 14 December 2021

Laravel faker package

When making web apps, developers often need a lot of test data. Making this data by hand can take a long time and not be very useful. This is when Laravel Faker comes in very handy. Laravel Faker is a useful library that lets developers make fake data that looks real for testing, development, and showing off.

Laravel's database seeding system works perfectly with Faker, which makes it easy to fill databases with sample records like names, emails, addresses, and more. Without using real user data, developers can quickly simulate real-world data.

Monday, 6 December 2021

Laravel InvalidArgumentException: Auth guard [api] is not defined

Getting to know the mistake:

When using Laravel or Lumen APIs, developers might see the error "Auth guard driver [api] is not defined." This error usually happens when the authentication system tries to use an API guard that isn't set up correctly in the authentication settings. Because of this, the framework can't figure out how API authentication should work.

You might see the error in different ways, like "InvalidArgumentException: Auth guard [api] is not defined" or "Lumen 5.4 – Auth guard driver [api] is not defined." No matter what the message format is, the problem is usually the same: the project's authentication configuration file is missing or has the wrong settings for the API guard.

Authentication guards in Laravel and Lumen tell the system how to check who is who for each request. The web guard is often used by web apps, and the token-based guard is often used by APIs. The system can't verify API requests if the API guard isn't set up correctly.

This problem happens a lot when developers make REST APIs, add authentication packages, or move projects from one version of Laravel to another. To fix this error quickly and make sure that API authentication is safe, you need to know how the auth.php file is set up.

Common Reasons


Here are some of the most common reasons why the "Auth guard driver [api] is not defined" error happens. 

1. API Guard Configuration is missing

This error happens most often because the config/auth.php file does not define the API guard. Laravel needs a guard configuration that tells the system which provider and driver to use for API authentication. This exception is thrown by the framework if the guard is not there. 

2. Wrong Authentication Driver 

The API guard is sometimes there, but the driver isn't set up right. For instance, if you are using Passport, JWT, or token authentication, the driver must match the package that is already installed. The error can happen when the driver and the authentication package that is already installed don't match. 

Sunday, 5 December 2021

Laravel Call to undefined function App\str_random()

When developers work with modern Laravel apps, they sometimes run into problems with helper functions that were in older versions of the framework. The "Call to undefined function App\str_random()" error is a common problem. This error usually happens after you upgrade Laravel or work with a newer version, when some helper functions have been moved or removed.

This guide will show you why this error happens and how to fix it quickly using a number of different methods.

.htaccess not working even though allowoverride is enabled

You're not the only one who has had the annoying problem with Apache where your file doesn't work even after you enable it. You'...