
Good content takes time and effort to come up with.
Please consider supporting us by just disabling your AD BLOCKER and reloading this page again.
In this article, you will learn how to start the PHP built-in web server. How to connect to your computer to mobile hotspot and test your PHP project from your computer in a mobile browser.
For the sake of demonstration I have created testserver
as PHP project inside htdocs
folder. You might be creating inside /var/www/html
depending on software you use in your computer. You might be having working project
Now in my testserver
project folder I have created index.php
and added the following code in it
<?php
echo 'Local Web Development Testing!';
NOTE: If your using any framework like LARAVEL / SYMFONY which points to public
folder then don't loose hopes I have even covered in this article, please continue reading
Now turn on your mobile hotspot and connect your laptop to it. I use ( Android ) Redmi Note phone and you can find the hotspot enabling option with the following, this will mostly remain same for other devices too
i. Settings -> Portable Hotspot ->Portable Hotspot ( Turn On By Clicking Switch Button )
ii. Click On Setup Portable Hotspot -> Set SSID & PASSWORD
Your all set to share & connect your hotspot with SSID & PASSWORD
After connecting your laptop to mobile hotspot. Go to your terminal and type the following command
MACBOOK / UBUNTU
ifconfig
Windows
ipconfig
You will see the ip address allocated to your laptop there, for example mine is shown in the following image
Now go to your PHP
project folder ie testserver
from the terminal and run the following command to turn on the PHP built in server.
sudo php -S 192.168.43.43:80
If you have any specific path like public
folder in you use LARAVEL
to start with then use -t
parameters as follows
sudo php -S 192.168.43.43:80 -t public
Here we are using the same IP Address192.168.43.43
as that of my laptop got assigned after connecting to mobile hotspot in Step 3. And I want it to get connected with port80
by default
You will get the following success output after running the above command
sudo php -S 192.168.43.43:8888
#ouput
Password:
PHP 7.2.21 Development Server started at Sat Apr 25 13:34:56 2020
Listening on http://192.168.43.43:8888
Document root is /Applications/MAMP/htdocs/testserver
Press Ctrl-C to quit.
[Sat Apr 25 13:35:11 2020] 192.168.43.1:45870 [200]: /
Public
Foldersudo php -S 192.168.43.43:80 -t public
Password:
PHP 7.2.21 Development Server started at Sat Apr 25 13:40:13 2020
Listening on http://192.168.43.43:80
Document root is /Applications/MAMP/htdocs/stackcoder/public
Press Ctrl-C to quit.
Now your application is ready to be access with http://192.168.43.43:80
URL. No need to add port 80 as its the default port for HTTP
. You can test the same in your laptop before going to your phone browser.
Now go to your phone browser and open the URL http://192.168.43.43 you will be able to see the application developed as shown in the following image
Public
FolderHope this article helped you. You might be interested in my other articles
Generate Fake Data In PHP With Faker
Global Data In All Laravel Blade Pages
Install Packages Parallel For Faster Development In Composer
Factory States For Clean And Fluent Laravel Testing
Generate Sitemap in PHP Laravel
Google reCAPTCHA Integration In PHP Laravel Forms
Free SSL Certificate With Lets Encrypt/Certbot In Linux (Single / Multiple Domains)
Multiple File Uploads In Laravel PHP
PHP file_put_contents failed to open stream: Permission denied
@stack @push and @prepend In Laravel Blade
Test Your Local Developing Laravel Web Application From Phone Browser Without Any Software
PHP Built-In Web Server & Testing Your Development Project In Mobile Without Any Software