Iam working on my own php MVC. And now, I wanted to create a cli tool for starting a live server which can be used for development purposes. I'm using laravel-zero for building my cli. All the commands are working fine except the command that is supposed to start a server. To start my server, first I need to change my current working directory to public and then start a php server using ' php -S localhost:9000 '
I have tried the below code, but it doesn't work:
shell_exec("cd public");
shell_exec("php -S localhost:9000");
I have also tried this, but this too doesn't work:
shell_exec("cd public ; php -S localhost:9000");
Finally after lots of google searches, I tried this, but the same result:
chdir("public");
shell_exec("php -S localhost:9000");
All It shows is just ' The system cannot find the path specified. '
If your current directory when running shell_exec()
is your installation root directory, you can just add the path after php
shell_exec("php -S localhost:9000 -t public/");
But since you are using laravel, why dont you just run php artisan serve
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.