-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Out-of-the-box Laravel Vapor support #5189
Comments
What we need to do here is create a list of things/problems/quirks that happen when using Backpack v6 on Laravel Forge... then see what we can do about each one. Problem 1. Basset needs to use the S3 bucket on Vapor. And for cache maps to be disabled. Thanks to @malek77z we've documented that process in the Basset docs. Problem 2. Uploads need to happen on the S3 bucket as well. This is pretty standard I think, but we do need to
Anything else I've missed @malek77z ? Note that I haven't deployed v6 on Vapor yet so I'm working blind here 😅 We're hard at work to finish up the v6 launch so the priority is that, at the moment. But as soon as we're done I'd like us to take a closer look at this. |
Very happy t help out an retrace my steps. I now have 3 projects on Backpack (now 6!) and Vapor, so confirmed it works well. Also Basset came just in time as the tweaks i made before to upload so many files stopped working just as basset was released! I'm going to assume that a Vapor project from https://vapor.laravel.com/ has been set up and there is an environment ready. So once the Vapor AWS is set up and connected to vapor, domain if you want one, database (im using db.t3.micros for now), you will need to log into Vapor on you CLI to connect the project.
then
You should end up with a yml file like the following in root called vapor.yml
This is my github action yml file in .github/workflows/deply.yml
Note the secrets set. If you are using pusher or similar, important to set here as they will get written into the js asset file, I might have gone a bit overkill with the env as Vapor basically writes its own, but this got me to a working action. So this should get git hub to put to Vapor now, and mostly work, but there are a few more things you have to be aware of. Next, for logos and so on in the ui.php config, when you want to pass them in you will also need to make sure your pointing to the correct place, this is an example I used in my config to make sure it was using the s3 bucket...
as you cant use asset() in the config, this works the same way Next is image uploading... This comes in 2 parts, 1 being able to write the image to S3 bucket, however you also need to think about the tmp upload folder, as although this may work uploading ot the tmp folder of a lambda, its not guarantied to work as you could be dealing with a different machine. this is my modified image.blade.php I use to do just that:
And this is me calling it
(note the tmp_disk attribute) We are still not there yet as we need to use laravel-vapor to do the client side uploading... this is my app.js in rescources/app.js which gets created with npm magic
for NPM you will make sure you have
also in the ui.php make sure your loading whereever the script is i.e.
This is an example, not the green checkmark to show its connected as expected. This is the other side, its my image trait I made to upload to s3 and so on
and this is me using it in my user model to upload avatars
Also, this was another important step, I needed to make sure i had a UserPolicy created like so:
to give vapor the permission to upload in the client side with this provider
which is put in app.php in the providers
Finally, I was having trouble getting larvel-vapor client upload understanding the backpack auth, due the guard being different. Setting the guard to null in base.php works i.e.
However I has a work around to run this in the crud which was a hack but worked:
This was a hack that worked, and sure a better way, but thats what i landed on before i wiped the guard. So thats about it. Im sure i have done some things in a round aout way, so very happy to hear improvements and so on! I especially think my lack of totally understanding on the AuthServiceProvider means im doing something the hard way around. Anyway, once all of this is done, i simply push production or staging and 5 min later up on vapor :-) One more note, make sure you have supplied VAPOR_API_TOKEN in github secrets, just ran into that on a new project |
Thank you SO MUCH @malek77z . Seems like we can do quite a bit to improve the DX for Vapor users. That's GREAT. It'll take us a while to process this and come up with appropriate, more general solutions. Seems like a Thanks again, we super appreciate it! |
Feature Request
What's the feature you think Backpack should have?
Backpack should be able to work out-of-the-box on Laravel Vapor and/or provide clear steps on how to deploy it there.
Have you already implemented a prototype solution, for your own project?
No but @malek77z has 👀
Do you see this as a core feature or an add-on?
Core, most likely.
The text was updated successfully, but these errors were encountered: