Laravel Hidden Features You Need to Know in 2023

Ismat Babirli
4 min readFeb 3
Photo by Fotis Fotopoulos on Unsplash

Laravel is a powerful PHP framework that has been around for over a decade. It has gained a massive following due to its elegant syntax, robust set of features, and ease of use. Whether you’re a seasoned Laravel developer or just starting out, there are a few hidden features that you might not be aware of. In this blog post, we’ll highlight some of the most useful Laravel hidden features that you need to know in 2023.

  1. Route caching

Route caching is a feature that was introduced in Laravel 5.5. It allows you to cache your application’s routes, which can significantly speed up your application’s boot time. To use route caching, simply run the following command in your terminal:

php artisan route:cache

2. Artisan command scheduler

The Artisan command scheduler allows you to schedule repetitive tasks in your application, such as sending emails, cleaning up old data, or updating your database. To use the Artisan command scheduler, you’ll need to add a task to the app/Console/Kernel.php file:

protected function schedule(Schedule $schedule)
{
$schedule->command('emails:send')
->dailyAt('9:00');
}

3. Automatic Namespace Model Detection

Laravel has a feature called automatic namespace model detection, which allows you to omit the namespace of your models when you are using them. For example, instead of writing:

$user = App\User::find(1);

you can simply write:

$user = User::find(1);

4. Model factories

Model factories are a great way to generate fake data for testing your application. You can define a factory for a model by creating a file in the database/factories directory. For example, here's a factory for a User model:

Ismat Babirli

Software Engineer and Tech Lover

Recommended from Medium

Lists

See more recommendations