Laravel 5.1 local server deployement - laravel-5

I have a project developed with laravel 5.1 and it successfully run on localhost:8000/. I want to make this project accessible by other users who are on the same network. Can any one help how to do this. I am using windows 10 currently.

first, you check your IP address of network then
for example, we consider IP = 192.162.2.5
now you check open you site passing url = 192.162.2.5:8000 or 192.162.2.5
if site not open then --
try the following command on cmd
method 1
php artisan serve --host 192.162.2.5 --port 80
now you open browser and pass URL = your IP (192.162.2.5)
method 2
if you want to your site run on port 8000
then run following command
php artisan serve --host 192.162.2.5 --port 8000
now you open browser and pass URL = your IP (192.162.2.5)

Related

Can't access localhost on other devices using php artisan serve

recently I was trying to access my laravel web app on the same wifi using another device and it works well(I copied the ipv4 into the --host). However, when I tried it on a different wifi, it doesn't work at all despite following the same steps and using the correct ipv4. May I ask why is that so and how do I fix it?
If you want to access it from another device you should enable it like so :
php artisan serve --host=0.0.0.0
it will allow any device in your network to access it,
and it will work with wifi and with ethernet
If you set your wifi ipv4 in the host but at the same time your are connected with ethernet it won't work
Run this on visual code or CMD, you must be in laravel directory,
php artisan serve --host=0.0.0.0
then just go to cmd and type the following:
ipconfig | findstr IPv4
Copy the IPV4 Address Your device IP, and then just simply paste it on your browser with the 8000 port, it should be like this example. (192.168.100.77:8000)
Enjoy Developing!

How to set port that Laravel runs on in a Portainer Docker Container

First post so apologies if it doesn't look great.
I used to have a Portainer Docker container running Laravel image "bitnami/laravel:latest" on host port 4001, but now i'm trying to re-create it and when accessing http://localhost:4001/
it shows this error:
This page isn’t working localhost didn’t send any data.
ERR_EMPTY_RESPONSE
The container has Manual network port publishing set to Host = 4001 and Container = 4000 and I think the problem is that Laravel isn't actually running on port 4000, so nothing is returned to the webpage.
My notes mention that the port is set in the Command, but they don't say how :-(
enter image description here
So, if anyone can tell me how to set the port via this command then i'd hugely appreciate it!
'/opt/bitnami/scripts/laravel/run.sh'
The run.sh script contains this line:
declare -a start_flags=("artisan" "serve" "--host=0.0.0.0" "--port=${LARAVEL_PORT_NUMBER}")
It looks like it starts Laravel on a port set by this parameter ${LARAVEL_PORT_NUMBER} so I was thinking something like the line below but that didn't work:
'/opt/bitnami/scripts/laravel/run.sh -LARAVEL_PORT_NUMBER 4000'
The container log (below) shows that Laravel starts up ok and it looks like it's saying it's on port 8000 but changing the container in the port publishing to 8000 doesn't work.
Starting Laravel development server: http://0.0.0.0:8000
[Sat Apr 9 20:44:05 2022] PHP 8.1.4 Development Server (http://0.0.0.0:8000) started
Let me know if any more information would help.
[edit]
Just realized I could edit run.sh and hardcode the port, like this:
declare -a start_flags=("artisan" "serve" "--host=0.0.0.0" "--port=4000")
After re-starting the container it's now working and the Laravel page loads in the browser! It's not ideal though so if anyone knows how to pass the port parameter to the bash script then that'd be great :-)
Many thanks!
Rob

tool like Ngrok to Access XAMPP Localhost from Internet

I have read this question, I found the best answer for me was : http://ngrok.com small tool
This tool is really great, but to add a custom domain you need paying plans
Is there any other tool like Ngrok to Access XAMPP Localhost from Internet
There npm module localtunnel.me which allows you to specify custom subdomain.
npm install -g localtunnel
then start tunnel like this
lt --port 8000 --subdomain yoursubdomain
then you'll be able to access it like subdomain.localtunnel.me

configure sinatra as a server

I have written an app in ruby using sinatra. the app works fine and I am testing the post/get request using postman.
Right now I start the app using the command rackup but it starts the server locally on the port 9292. using postman, I send the POST on localhost:9292
I would like to test the app when access from another computer. I expect something using POSTMAN sending a POST on http://182.12.34.1:9292 but I didn't find how to do this.
config.ru
load './app/init.rb'
run Sinatra::Application
Procfile
web: bundle exec unicorn -p $PORT -E $RACK_ENV -c ./config/unicorn.rb
Any idea, how to switch from local test to a server ?
Thansks
The easiest way is to use an existing tool like ngrok or localtunnel.
If you have npm installed, then you can do this in a new terminal:
sudo npm install -g localtunnel
lt --port 9292
It will then give you a URL that you can share. Keep in mind these two things:
The URL is only valid as long as the localtunnel process is running
You still need to have your server running on localhost:9292 for it to work.
Did you perhaps listen to localhost only in the config?
You need to bind the host to 0.0.0.0 otherwise it will only only be available locally...

debugging laravel artisan from PHPStorm with homestead

I setup Laravel Homestead. I then configured both homestead xdebug.ini and PHPStorm to make the debugging work.
Here is my xdebug.ini inside homestead
zend_extension=xdebug.so
xdebug.remote_autostart = on
xdebug.remote_enable = on
xdebug.remote_connect_back = on
xdebug.remote_port = 9000
xdebug.idekey = "vagrant"
To start a debugging session the steps I follow are
In PHPStorm --> Start Listening for connections
In PHPStorm set a breakpoint
In my browser --> Use XDebug Chrome Helper OR add to my URL ?XDEBUG_SESSION_START=
Load the page
This works perfectly. My problem is when I'm inside homestead command line and I run a php artisan command then I can't get it to hit my breakpoints.
What I've tried
XDEBUG_CONFIG="idekey=PHPSTORM" PHP_IDE_CONFIG="serverName=server_name" php -dxdebug.remote_host="127.0.0.1" artisan mycommand
php -d xdebug.profiler_enable=On artisan mycommand
I also tried to set xdebug.remote_autostart=On then sudo service php5-fpm restart but still my breakpoints never get hit in PHPStorm
Two things are important:
remote_connect_back can not work in the CLI case because Xdebug can not detect the remote IP when you are in the console
When using homestead / VirtualBox in the NAT network configuration, your development machine (which is running PHPStorm) does not have the IP 127.0.0.1 seen from inside the VM. Instead, it has usually an IP like 10.0.2.2. To find out the correct IP, have a look at your Apache's access.log,
The following worked for me:
php -dxdebug.remote_autostart=on -dxdebug.remote_connect_back=off
-dxdebug.remote_host=10.0.2.2 artisan
edit If your breakpoints are not hit, you have to set up the folder mappings correctly (as your path in the IDE is different from what the web server sees:
Do export PHP_IDE_CONFIG="serverName=yourservername" in your VM, where yourservername is what you configured in the screenshot under "name"
Add a Php Remote Debug Configuration with an IDE key and the server configured above
And add your IDE key and the remote_host to the VM's XDEBUG-CONFIG
export XDEBUG_CONFIG="idekey=artisan remote_host=10.0.2.2"
References: http://randyfay.com/content/remote-command-line-debugging-phpstorm-phpdrupal-including-drush
Or, if that all is just too complicated or not working - you can trigger your artisan command via a url (route) using
Artisan::call('whatever:command');
In most recent versions of Homestead you can do xphp artisan whatever and phpstorm will popup a windows automatically.
https://laravel.com/docs/8.x/homestead#debugging-cli-applications

Resources