Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

everetts's avatar

spark production - deploy repository on forge

I own a valid spark unlimited license, forge, envoyer and laracast subscriptions. I've created a new spark app on my dev machine and the private repository is valid in bitbucket. I'll update all the dependencies, including Spark and Laravel on my production server when updating/upgrading versions, but once I've set my version release and updated the repository, I don't want to have to Composer update as it might break.... It also requires me to get a new bitbucket key each time I install the repository.

I'm trying to figure out how to set a version and dependencies that stay static and doesn't update so I can auto deploy the version without being interrupted for new keys for the spark update (I have a valid spark unlimited license).

If installing the repository and keeping the install composer dependencies check in forge, it fails like this, but I can get around it Generating autoload files > Illuminate\Foundation\ComposerScripts::postInstall > php artisan optimize [Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Laravel\Spark\Providers\SparkServiceProvider' not found

So here is the only way I can install the repository on a new server in forge (I'll use envoyer later once this issue is debugged), here is the process I'm required to go through for it to actually work:

  1. Uncheck install composer dependencies when installing repository.
  2. composer update --no-scripts -o
  3. This forces a new key from bitbucket to be pasted, and it gives the bitbucket link to add it.
  4. php artisan key:generate
  5. php artisan migrate (only for creating a new database)

I'm missing something, obviously, I want to be able to spin up a server without updating or adding new keys. Any help would be great. Thanks.

e

0 likes
3 replies
everetts's avatar

So my .gitignore had the /vendor in it, therefore when I ran composer update, there were no dependencies so it installed them again, which required the new key for spark and reinstalled the dependencies. Composer update will not reinstall your dependencies in your composer.lock file unless the vendor file and/or the dependency aren't there, then it treats it as composer install and installs any missing dependencies..

I took out /vendor from my .gitignore and just cloned the repository to a forge server, updated my .env and it works great.

There are two opinions about the composer.lock and /vendor in .gitignore, some say keep, some not. In the end I decided that having the files would help me down the road to know what dependencies I had used, in the event that it had been a long time between versions and I had done many commits on the dev side.

I also like having the /vendor with the dependencies as who knows, a dependency may no longer be available and then I'd be sol.

e

ahuggins's avatar

I think this is because the way that Spark works. Spark is a composer dependency itself, so when you are deploying the repo, that already has Spark installed, the SparkServiceProvider is already added to your config/app.php. So when you go to deploy, it throws the error.

This is why you need to uncheck the "install composer dependencies" and you will need to ssh into the server and install spark...probably only going to have to this once. Once Spark is installed, then adding composer packages should be fine. Or at least that's what it seems this thread suggests: https://laracasts.com/discuss/channels/spark/installing-spark-site-on-forge

1 like

Please or to participate in this conversation.