Same project, 2 apps
Hello, I'm using filament to build an admin panel, and the app for the user is in reactjs
is it possible to have them all in the same laravel project?
and then deploy them liike that, with different domain names? (one should be the official, the other should contain admin in the domain name)
29 Replies
Yes, this should be possible. There are many ways you can arrange a project like this... Here's a demo using Filament for content entry and Astro.js for the front-end. It's still a work in progress but it can give you one option of how to go about it:
https://github.com/pboivin/filament-peek-demo-with-astro
At the top-level, there's the Filament app used for content entry
And within
frontend/
there's the Astro.js project
In this example, I'm deploying both apps separately, but it would be possible to deploy it in one step on the same server.
You could configure it at 2 sites in nginx, one serving the Laravel app at /my/project/public/
and the other serving the front-end at /my/project/frontend/dist/
.
Hope that makes sense.@pboivin thank you so much
In fact, I'm actually a beginner, never dealt with this before
but in general, is it better to do both together or separately,
I chose this bcz the db is supposed to be common, so, I'm not sure if having distinct backends will serve the purpose
If you're a beginner and unsure of where to go, I would recommend going with Inertia.js in this context.
Here's a full tutorial on how to build a Laravel app with a React frontend in the same project:
https://bootcamp.laravel.com/inertia/installation
Laravel Bootcamp - Learn the PHP Framework for Web Artisans
Together let's walk through building and deploying a modern Laravel application from scratch.
And you can still use Filament, all in the same project
For me, it's better to do it together because I'm a team of 1. If you're on a large team with a clear separation between front and back, then maybe it's better to separate it.
okey, I'll take your advice!
thank you Patrick, you're a real support π
I might reach you out in this thread later if possible, since the project isn't fully done yet :'")
Sure, feel free to reach out
@pboivin Sorry for asking again
But in fact, the react app is already made in react js framework, but not deployed,
is there anyway to use that code?
or it has to be deployed independtly from the laravel project and does some axios requests to the backend server, which at the same time contains the whole panel,
Like I mentioned above, there a many ways to organize a project like this... it really depends on your experience (and/or your team...)
But maybe I can give you some pointers. How is your app deployed currently? Or is this a completely new project?
it's a new project
@pboivin
Ok, that's good. So just thinking about the backend for a minute, how are you going to deploy the Laravel app?
It's an internship in a company, they said it's gonna be deploy in their servers (I just no dockerization, but I've actually never deployed an app myself, soo idk)
How about locally, on your computer. How are you running the project at the moment?
I'm the one who is working on the admin panel, so yeah, only laravel,
my friend is running react and laravel separately
well, both local host,
Ok, so your friend is running both apps on localhost on different ports? And the react app gets content from the laravel app via an API?
she's still making the APIs, but yeah, this is the current logic
so you mean we deploy them the same way
Yes, I'm thinking it could be the simple option. If you have people at work who are in charge of servers + deploying apps, it shouldn't be a problem.
What about the domain name configuration?
Let's say for example that your React app will be
mysite.com
and your backend will be api.mysite.com
hey i'm her friend
Both domains can point to the same server, that's not a problem
Welcome ^^
so basically it's gonna be something that makes the localhost->react.com
localhost of the server, i mean
Sort of, yes. This is the job of the web server (Nginx, or Apache, etc.)
So both domains can point to 1 server, and this server knows that the requests for
mysite.com
go to the React app, and so on
Is there anyone at work you can talk to about that? Can you email or call someone who's in charge of the domains and the web servers?I'm gonna contact them for this, but the approach overall is correct right?
Yes, this is how I do it. Both apps can be in the same Git repository, so it's easier to work on and to deploy. And then on the production server, you can assign each app to its own domain.
I mean when we came to do the typical react+laravel app, we found that the current code might not be so useful, @rosie has a good experience with React
so, anyway it made it a bit difficult to use intertia honestly,,
I'll look up more resources to see how to deploy them correctly,
I'll also seek advice from the server manger in that company
Yeah, I think Inertia is great, but it's true that it's not the "typical React".
@rosie just to summerize:
react app runs onlocal host on a port
laravel runs on a different one,
react sends api calls to the laravel app deployed in the same server but runs on a different port,
domain names will be: one domain name for react app,
the other references the admin panel in laravel,
and everything should work since they're both in the same server
Thank you so much Patrick
You're welcome, good luck to you both!
yes thank you so much patrick !