0

I know how to run a php built it server from the command line and I know how to execute files from the command line, but what if i want to run a file from php command line interface and run php built-in server from the code inside the file executed by php cli.

Is it possible. If yes, how?

If no, Then how does the laravel runs the php builtin server by artisan command.

3
  • 1
    Have you looked into the shell_exec() command? Check out the documentation for that. Commented Mar 29, 2018 at 19:49
  • @jase thank you exactly want i was looking for Commented Mar 29, 2018 at 19:52
  • php.net/manual/en/function.shell-exec.php Commented Mar 29, 2018 at 19:53

1 Answer 1

1

There are multiple ways to executing commandline programs from PHP. There are shell_exec and proc_open. shell_exec is the easiest one of them both.

<?php
  echo shell_exec("whois domain.com"); 
?>

which will output the result from the whois command.

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

http://php.net/manual/en/function.proc-open.php

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

Comments

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.