Skip to content

Commit

Permalink
add docs to loadCacheRoutes in RouteServiceProvider (#902)
Browse files Browse the repository at this point in the history
* adding support for laravel 11

* adding docs to support laravel 11

* adding docs to support laravel 11

* remove class
  • Loading branch information
ahmedabdel3al authored Jul 24, 2024
1 parent 0164afa commit 42ea38f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CACHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ If you want to cache the routes in all languages, you will need to use special A

For the route caching solution to work, it is required to make a minor adjustment to your application route provision.


**before laravel 11**
In your App's `RouteServiceProvider`, use the `LoadsTranslatedCachedRoutes` trait:

```php
Expand All @@ -14,7 +16,23 @@ class RouteServiceProvider extends ServiceProvider
{
use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes;
```
**after laravel 11**
In your App's `AppServiceProvider`, use the `CachedTranslatedRouteLoader` class in register method:

```php
<?php
class AppServiceProvider extends ServiceProvider
{
use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes;
/**
* Bootstrap any application services.
*/
public function boot(): void
{
RouteServiceProvider::loadCachedRoutesUsing(fn() => $this->loadCachedRoutes());
...
}
```

## Usage

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ php artisan route:trans:cache

For the route caching solution to work, it is required to make a minor adjustment to your application route provision.

**before laravel 11**

In your App's `RouteServiceProvider`, use the `LoadsTranslatedCachedRoutes` trait:

```php
Expand All @@ -515,6 +517,26 @@ class RouteServiceProvider extends ServiceProvider
use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes;
```

**after laravel 11**

In your App's `AppServiceProvider`, use the `CachedTranslatedRouteLoader` class in register method:

```php
<?php
class AppServiceProvider extends ServiceProvider
{
use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes;
/**
* Bootstrap any application services.
*/
public function boot(): void
{
RouteServiceProvider::loadCachedRoutesUsing(fn() => $this->loadCachedRoutes());
...
}
```



For more details see [here](CACHING.md).

Expand Down

0 comments on commit 42ea38f

Please sign in to comment.