Hello Brian,
It sounds like you're trying to deploy a project on Laravel Forge, but Forge is expecting a composer.json file at the root of your repository because it's designed to work with PHP projects (like Laravel) out of the box.
If your back-end is a PHP/Laravel project, you should ensure that the composer.json file is located at the root of your repository. However, since you mentioned that you have two directories, one for the front-end and one for the back-end, it seems like your project structure is not what Forge expects by default.
Here's what you can do to resolve this issue:
-
Move the
composer.jsonto the root: If possible, restructure your repository so that thecomposer.jsonfile for your back-end is in the root of the repository. This is the simplest solution and will allow Forge to recognize your project as a PHP project. -
Use a Custom Deployment Script: If restructuring the repository is not an option, you can use a custom deployment script in Forge to navigate to your back-end directory and run
composer installfrom there. Here's an example of what that script might look like:
cd /home/forge/default/back-end
composer install --no-interaction --prefer-dist --optimize-autoloader
# Add any additional deployment steps for your back-end below
# ...
# Now navigate to your front-end directory and build your assets
cd /home/forge/default/front-end
# Run npm/yarn commands or any other build steps you have
# npm install
# npm run prod
Replace /home/forge/default/back-end and /home/forge/default/front-end with the actual paths to your back-end and front-end directories within the Forge server.
To add a custom deployment script in Forge:
- Go to your site on Forge.
- Click on the "Deploy" tab.
- Scroll down to "Deployment Script".
- Edit the deployment script to match the one you need (similar to the example above).
Remember to commit any changes you make to your composer.json or deployment scripts to your Git repository before triggering a deployment on Forge.
I hope this helps you get your project up and running on Forge! If you have any more questions or need further assistance, feel free to ask.