Run Vue.js and Laravel on the same server (same port) - php

I am developing a website using Laravel as backend and Vue.js 2 as frontend. Now everytime i want to run my website I have to use 2 command:
php artisan serve
This will run the laravel server on port 8000
npm run dev
This will run the vue.js server on port 8080
Can I just run them on the same server (same port), with just one command only??

If you use the Laravel app with Vue.js included in it, you don't need to run npm run dev.
In your case, you seem to have a decoupled frontend and backend. In that case, you don't really have the choice to host 2 different ports or hostname.
You can use the same port if you use a different domain. For example, you can use mydomain.com for the frontend and use api.mydomain.com for the backend/api.
Assuming you have a webpack frontend project, you can do npm run build, which will compile all your files to static html files in the dist folder. You then only need to point your host configuration file to this folder.

Related

How can I make the npm start IP address sync with php artisan serve to use backend functionality on mobile device?

I have a React.js frontend project and Laravel backend project separated. I can access my frontend project via the local host address provided upon running npm start so I can see the frontend on a physical device of what I'm working on.
However - When I try to login (backend functionality) on my physical device, it won't allow me to. php artisan serve's running on my backend project and I can successfully login on the browser without any issues so my login system isn't the issue.
I guess my question is - how can I make it so that my physical device knows that php artisan serve's running so I can access my web app with the localhost address given to me provided by npm start?
In other words - how can I make 127.0.0.1:8000 (php artisan serve) sync up with 192.168.2.165:3000 (npm start)?
I think you want to have your app request proxied to your backend server. take a look at this from Create-react-app doc : https://create-react-app.dev/docs/proxying-api-requests-in-development/
Based on your description you should add this line to your package.json for your react app :
"proxy": "http://192.168.2.165:8000"

How can I create a local installation of a php app?

Basically I want to know if it's possible to create a local installation of a PHP application with his own database and with the .exe bringing embedded XAMP with Apache?
So the client just executes the .exe and click next..next..next and the app has his icon and ready to use without further configuration.
You can do setup your PHP app in the Docker container. And to configure the docker app on the client machine he can use docker desktop application for mac/windows.
Once the docker desktop will be installed then he can run the app using just one docker command.
docker-compose up -d
Your app will be up and running on any one machine. But if you're new with docker then set up your app in docker could be a little challenging.
Ref: https://docker-curriculum.com/

Using Apache-PHP as a Runner in AWS Cloud9

I am using AWS Cloud9 as my IDE for PHP web development. I have set up the environment on AWS with all the default settings and all appears to be working. I can use the "Run" and "Preview" functions in the IDE to run my .php file. However, it is using the "PHP (Built-in web server)" as default to run.
How do I run it through Apache HTTP instead? There isn't an option in the list of Runners. I can create one, but have no idea how to. I can see that Apache HTTP is available on the default EC2, though.
There is no option in the list of runners. You have to manually configure Apache to run on ports 8080, 8081 or 8082.
This page details how to run Apache on AWS EC2 Cloud9 server (port, root directory and htaccess): How to configure and run Apache server on AWS EC2 Cloud9?

How to give on local to other pc access to your project in valet?

When I make a project in laravel I can give access with php artisan serve but if a make a normal project and make host with valet link the PHP artisan don't work because it's not a laravel project. How can i give access to local with valet ? For example i have project.dev and make 192.168.1.5:80 like in laravel.
You can use the valet park or valet link commands to be able to access your application locally.
For a local network, you will need to make sure your port is accessible if your're behind a firewall. You may need to setup port forwarding, as well, if NAT is involved.
Are you trying to make the project accessible to others on the internet? For this, you can use ngrok.
https://ngrok.com/
”I want to expose a local server behind a NAT or firewall to the internet.”

How to deploy symfony 2 app

I am new to symphony2 and I need to know how can I make my application run without the server:run commmand. What do I need to do to be able to make it run inside the root folder of my nginx server on port 80?
There are several steps you need to do.
1. Install Apache or similar web server on your hosting server.
2. Create a virtual host which points to the directory where your Symfony app is.
3. Allow proper permissions to folders.
4. Run your web server from specific console command.
Refer following two URLs for more details:
http://symfony.com/doc/current/cookbook/deployment/tools.html
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-symfony-application-to-production-on-ubuntu-14-04

Categories