php - View composer not working properly in testing mode in Laravel 5.2 -
i've view composer written this
view()->composer('masterbox.partials.pipeline', function($view) { // vars , code });
in 1 of view follow
@include('masterbox.partials.pipeline', ['my_var' => 1])
when i'm trying on browser fine, when run simple test blows ... after debugging found out closure wasn't executed @ all.
$this->visit('/connect/customer/subscribe') ->type($faker->firstname, 'first_name') ->type($faker->firstname, 'first_name') ->type($faker->lastname, 'last_name') ->type($faker->email, 'email') ->type($faker->phonenumber, 'phone') ->type($password, 'password') ->type($password, 'password_confirmation') ->press("s'inscrire");
note : visits page, fills form , subscribe, redirects on page @include
, returns big error, part of is
exception 'errorexception' message 'undefined variable: my_var' in /users/loschcode/google drive/projects/my_project_lo/website/storage/framework/views/7e11f284c02bc38adc60b5f8a0545df65d7cf5ec.php:7
i'm afraid issue, it's fresh laravel 5.2 downloaded few days ago. guess ? method debug ? thanks
working solution
i ended trying anything. problem service provider organization.
namespace app\providers; use illuminate\support\serviceprovider; class composerserviceprovider extends serviceprovider { /** * bootstrap application services. * * @return void */ public function boot() { foreach (glob(app_path().'/http/viewcomposers/*.php') $filename){ require_once($filename); } } /** * register application services. * * @return void */ public function register() { // } }
if have similar organization , problem, replace require_once
simple require
, go fine.
namespace app\providers; use illuminate\support\serviceprovider; class composerserviceprovider extends serviceprovider { /** * bootstrap application services. * * @return void */ public function boot() { foreach (glob(app_path().'/http/viewcomposers/*.php') $filename){ require($filename); } } /** * register application services. * * @return void */ public function register() { // } }
Comments
Post a Comment