Reputation: 31
I would like to execute the following command : composer update
in my controller in laravel, however this one does not work.
On the other hand the command composer info
works perfectly.
When I execute composer update
in a command prompt all my dependencies are correctly updated in the laravel vendor file but when I try to execute composer update
in my controller nothing happens.
here is my code :
$data['output'] = shell_exec( 'cd '. base_path() .' && composer update' );
dd($data);
and here is the result :
array:1 [▼
"output" => null
]
Could you help me to understand why composer update
does not work in a controller ?
I would like to update my dependencies in a controller without the command prompt.
Thank you.
Upvotes: 3
Views: 1857
Reputation: 1451
From the php docs for shell_exec()
:
The output from the executed command or NULL if an error occurred or the command produces no output.
Sounds like you'd be better off using passthru()
instead as that will give you the erroneous output.
Speaking of erroneous, this is idea sounds like a recipe for unmitigated disaster.
Upvotes: 2