F
Filamentβ€’15mo ago
Xe

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
Patrick Boivin
Patrick Boivinβ€’15mo ago
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.
Xe
XeOPβ€’15mo ago
@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
Patrick Boivin
Patrick Boivinβ€’15mo ago
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.
Patrick Boivin
Patrick Boivinβ€’15mo ago
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.
Xe
XeOPβ€’15mo ago
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 :'")
Patrick Boivin
Patrick Boivinβ€’15mo ago
Sure, feel free to reach out
Xe
XeOPβ€’15mo ago
@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,
Patrick Boivin
Patrick Boivinβ€’15mo ago
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?
Xe
XeOPβ€’15mo ago
it's a new project @pboivin
Patrick Boivin
Patrick Boivinβ€’15mo ago
Ok, that's good. So just thinking about the backend for a minute, how are you going to deploy the Laravel app?
Xe
XeOPβ€’15mo ago
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)
Patrick Boivin
Patrick Boivinβ€’15mo ago
How about locally, on your computer. How are you running the project at the moment?
Xe
XeOPβ€’15mo ago
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,
Patrick Boivin
Patrick Boivinβ€’15mo ago
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?
Xe
XeOPβ€’15mo ago
she's still making the APIs, but yeah, this is the current logic so you mean we deploy them the same way
Patrick Boivin
Patrick Boivinβ€’15mo ago
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.
Xe
XeOPβ€’15mo ago
What about the domain name configuration?
Patrick Boivin
Patrick Boivinβ€’15mo ago
Let's say for example that your React app will be mysite.com and your backend will be api.mysite.com
rosie
rosieβ€’15mo ago
hey i'm her friend
Patrick Boivin
Patrick Boivinβ€’15mo ago
Both domains can point to the same server, that's not a problem
Xe
XeOPβ€’15mo ago
Welcome ^^ so basically it's gonna be something that makes the localhost->react.com localhost of the server, i mean
Patrick Boivin
Patrick Boivinβ€’15mo ago
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?
Xe
XeOPβ€’15mo ago
I'm gonna contact them for this, but the approach overall is correct right?
Patrick Boivin
Patrick Boivinβ€’15mo ago
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.
Xe
XeOPβ€’15mo ago
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
Patrick Boivin
Patrick Boivinβ€’15mo ago
Yeah, I think Inertia is great, but it's true that it's not the "typical React".
Xe
XeOPβ€’15mo ago
@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
Patrick Boivin
Patrick Boivinβ€’15mo ago
You're welcome, good luck to you both!
rosie
rosieβ€’15mo ago
yes thank you so much patrick !
Want results from more Discord servers?
Add your server