0

I'd like to create a php script which connects to a mysql server, makes changes on a database and runs a php artisan command.

The first part I have figured out (mysql connection) but is it possible to just put (for example):

php artisan snipeit:ldap-sync --location_id=1

into my script and it will run the command, or am I missing something here?

I'd appreciate it if you could send me into the right direction wtih this. Thank you.

2 Answers 2

2

You can use Artisan::call().

Artisan:call('snipeit:ldap-sync', [
    '--location_id' => 1
]);

It can also take a second parameter to specify an array of command parameters.

For more information, see Programmatically Executing Commands.

Sign up to request clarification or add additional context in comments.

Comments

1

You can call artisan command from code like this:

Artisan::call('cache:clear');

1 Comment

So probably like this: Artisan:call('snipeit:ldap-sync --location_id=1'); ? Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.