paranoid
paranoid

Reputation: 7105

Run composer dump-autolaod in php

I add service provider dynamically in my project and I need run composer dump-autoload.
But it use system funtion system('composer dump-autoload'); and I am not have system ,exce ,... permission on my host. What am I do? Can I add my service provider manually to composer. I add to autoload_classmap.php and autoload_psr4.php but I have service provider error

Upvotes: 1

Views: 355

Answers (3)

Niraj Shah
Niraj Shah

Reputation: 15457

You can try calling the following from your code:

Artisan::call('optimize');

It does the same things as composer dump-autoload, but using an Artisan command.

Remember to add use Artisan to the top of your class.

Upvotes: 2

Ashouri
Ashouri

Reputation: 906

you should change PHP.ini configuration on your server :

Open a terminal or login to your server over the ssh session. Open php.ini file:

# vi /etc/php.ini

Find disable_functions and set new list as follows:

disable_functions =exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source

Then you can remove, for example system or exec from the list

Save and close the file. Restart the httpd server by tying the following

command:
# service http restart

Also you can probably use ini_set in your php code.

I hope it helps you.

Upvotes: 2

Mubashar Abbas
Mubashar Abbas

Reputation: 5663

Try the php exec function.

exec('composer dump');

Hope this works!

http://php.net/manual/en/function.exec.php

Upvotes: 1

Related Questions