You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found that by simply having a view()->composer() in my service provider it dramatically slows down my phpunit test suite and somewhat slows down my page loads even on pages that the view composer is not being used on.
If I comment out the composer lines, the unit tests go quickly. I have even tried the most basic of composers just make sure it's not the view file or the contents of the callback that is slowing it down and yes the 'test' view does exist.
view()->composer('test', function(){});
I have tried switching the order of the service providers, moving the composer code to a different provider and nothing makes it better other than literally removing/commenting out the composer lines. I'm at a loss. I have the same concept stuff in another app with no issues. Google has gotten me nowhere.
My app is currently on v11.44 but I have another app on v11.32 that uses view composers without any slow-down. I'm concerned about updating that as it may cause the issue to happen in that app too.
I need your suggestions!
<?php
namespace App\Providers;
use App\Helpers\Cart\Facades\Cart;
use App\Models\Products\Category;
use Illuminate\Support\ServiceProvider;
/**
* Class ViewComposerProvider
* @package App\Providers
*/
class ViewComposerProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
view()->composer('layouts.partials.cart.cart-link', function($view){
$view->with('cart_count', Cart::count());
});
view()->composer('layouts.partials.category-dropdown', function($view){
$view->with('categories_menu', Category::notPrivatized()->get());
});
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have found that by simply having a view()->composer() in my service provider it dramatically slows down my phpunit test suite and somewhat slows down my page loads even on pages that the view composer is not being used on.
If I comment out the composer lines, the unit tests go quickly. I have even tried the most basic of composers just make sure it's not the view file or the contents of the callback that is slowing it down and yes the 'test' view does exist.
I have tried switching the order of the service providers, moving the composer code to a different provider and nothing makes it better other than literally removing/commenting out the composer lines. I'm at a loss. I have the same concept stuff in another app with no issues. Google has gotten me nowhere.
My app is currently on v11.44 but I have another app on v11.32 that uses view composers without any slow-down. I'm concerned about updating that as it may cause the issue to happen in that app too.
I need your suggestions!
Beta Was this translation helpful? Give feedback.
All reactions