This is the official Spin template for Laravel that helps you get up and running with:
- Latest version of Laravel
- SQLite
We have a "Spin Pro Laravel Template" that includes more features for Laravel Pros:
Feature | Spin Basic Laravel Template | Spin Pro Laravel Template |
---|---|---|
Price | Free | $199/once (lifetime access) |
Automated Deployments with GitHub Actions | β | β |
Local Development SSL | β | β (Trusted) |
Tunnel Support | β | β |
SMTP Trapping | β | β (Mailpit) |
Vite over HTTPS | β | β |
Databases | SQLite | β MariaDB, MySQL, PostgreSQL, SQLite |
Redis | β | β |
Laravel Horizon | β | β |
Laravel Reverb | β | β |
Laravel Queues | β | β |
Mailpit over HTTPS | β | β |
Node Package Manager | yarn |
yarn or npm |
Support | β Discord, GitHub Discussions | β Private Community Support |
If you're interested in the Pro version, you visit https://getspin.pro for more information.
To use this template, you must have Spin installed.
spin new laravel my-laravel-app
By default, this template is configured to work with spin deploy
out of the box. If you prefer to use CI/CD to deploy your files (which is a good idea for larger teams), you'll need to make additional changes (see the "Advanced Configuration" section below).
Before running spin deploy
, ensure you've complete the following:
- ALL steps from "Required Changes Before Using This Template" section have been completed
- You've customized and have a valid
.spin.yml
file - You've customized and have a valid
.spin-inventory.yml
- Your server is online and has been provisioned with
spin provision
Once the steps above are complete, you can run spin deploy
to deploy your application:
spin deploy <environment-name>
- Laravel: http://localhost
- Mailpit: http://localhost:8025
Caution
You need to make changes before using this template.
By default, this template is configured to use spin deploy
which defaults to the production
environment. You need to create an .env.production
file in the root of your project.
cp .env.example .env.production
Configure your .env.production
file with the appropriate values for your production environment. Ensure APP_URL
is set correctly. Spin will use the domain from that variable as the production URL by default.
Almost everyone wants to run HTTPS with a valid certificate in production for free and it's totally possible to do this with Let's Encrypt. You'll need to let Let's Encrypt which domain know what domain you are using.
Warning
You must have your DNS configured correctly (with your provider like CloudFlare, NameCheap, etc) AND your server accessible to the outside world BEFORE running a deployment. When Let's Encrypt validates you own the domain name, it will attempt to connect to your server over HTTP from the outside world using the HTTP-01 challenge. If your server is not accessible during this process, they will not issue a certificate.
# File to update:
# docker-compose.prod.yml
labels:
- "traefik.enable=true"
- "traefik.http.routers.my-php-app.rule=Host(`${SPIN_APP_DOMAIN}`)"
By default, if you're using spin deploy
it will use the APP_URL
from your .env.<environment>
file to generate the SPIN_APP_DOMAIN
. You can also be explicit and change ${SPIN_APP_DOMAIN}
to myapp.example.com
.
Let's encrypt requires an email address to issue certificates. You can set this in the Traefik configuration for production.
# File to update:
# .infrastructure/conf/traefik/prod/traefik.yml
certificatesResolvers:
letsencryptresolver:
acme:
email: "[email protected]"
Change [email protected]
to a valid email address. This email address will be used by Let's Encrypt to send you notifications about your certificates.
By default, we have Laravel Automations configured to run with the serversideup/php Docker image.
If you do not want this behavior, you can remove the AUTORUN_ENABLED
environment variable from the php
service in the docker-compose.prod.yml
file.
# File to update:
# docker-compose.prod.yml
php:
image: ${SPIN_IMAGE_DOCKERFILE}
environment:
- AUTORUN_ENABLED: "true" # π Remove this line if you don't want Laravel Automations
If you're using an existing project with SQLite, you will need to move your database to a volume, especially if you're deploying to production with these templates.
Laravel comes with the default path of database/database.sqlite
. This path is not ideal for Docker deployments, because the parent directory of this file contains other database files used by Laravel.
For Docker Swarm (what is used in production), we need to place the SQLite in a dedicated folder so we can mount a Docker Volume to ensure the data persists.
To prepare the project, we automatically set the DB_DATABASE
environment variable.
# Set absolute path to SQLite database from the container's perspective
DB_DATABASE=/var/www/html/.infrastructure/volume_data/sqlite/database.sqlite
NOTE: Notice how this is the ABSOLUTE path to the database file. The reason why we use /var/www/html
is because that is the absolute path to the file in the eyes of the CONTAINER (not the host machine).
Your project folder is mounted as /var/www/html
inside the container. You simply need to ensure the .infrastructure/volume_data/sqlite/database.sqlite
file exists in your project folder on your host. Move your existing database file to this location if you want to migrate your data.
We automatically create a database_sqlite
volume in production. This volume is mounted to /var/www/html/.infrastructure/volume_data/sqlite/
to the php
service.
In development, you may want to run artisan commands or composer commands. We can use spin run
or spin exec
to run these commands.
spin run php php artisan migrate
The above command will create a new container to run the php artisan migrate
command. You can change run
for exec
if you'd like to run the command in an existing, running container.
spin run php composer install
The above command will create a new container to run the composer install
command. This is helpful if you need to install new packages or update your composer.lock
file.
If you need to attach your terminal to the container's shell, you can use spin exec
:
spin exec -it php sh
This will attach your terminal to the php
container's shell. If you're using an Alpine image, sh
is the default shell. If you're using a Debian image, you can use bash
instead of sh
.
Feel free to run any commands you'd like with spin run
or spin exec
. The above examples should help give you patterns what you need to do.
If you'd like to further customize your experience, here are some helpful tips:
We provide certificates by default. If you'd like to trust these certificates, you need to install the CA on your machine.
Download the CA Certificate:
You can create your own certificate trust if you'd like too. Just simply replace our certificates with your own.
If you're using CI/CD (and NOT using spin deploy
), you'll likely want to change the image name in the docker-compose.prod.yml
file.
php:
image: ${SPIN_IMAGE_DOCKERFILE} # π Change this if you're not using `spin deploy`
Set this value to the published image with your image repository.
When running spin deploy
, we automatically grab the MD5 hash value of the Traefik configuration and set it to SPIN_TRAEFIK_CONFIG_MD5_HASH
. This efficiently ensures your Docker Swarm Configuration is always up to date.
Be sure to change this value or set the MD5 hash so you can continue to receive the benefits of getting the best deployment strategy when updating Docker Swarm configurations with Traefik.
configs:
traefik:
name: "traefik-${SPIN_TRAEFIK_CONFIG_MD5_HASH}.yml"
file: ./.infrastructure/conf/traefik/prod/traefik.yml
- Website overview of the product.
- Docs for a deep-dive on how to use the product.
- Discord for friendly support from the community and the team.
- GitHub for source code, bug reports, and project management.
- Get Professional Help - Get video + screen-sharing help directly from the core contributors.
As an open-source project, we strive for transparency and collaboration in our development process. We greatly appreciate any contributions members of our community can provide. Whether you're fixing bugs, proposing features, improving documentation, or spreading awareness - your involvement strengthens the project. Please review our contribution guidelines and code of conduct to understand how we work together respectfully.
- Bug Report: If you're experiencing an issue while using this project, please create an issue.
- Feature Request: Make this project better by submitting a feature request.
- Documentation: Improve our documentation by contributing to this README
- Community Support: Help others on GitHub Discussions or Discord.
- Security Report: Report critical security issues via our responsible disclosure policy.
Need help getting started? Join our Discord community and we'll help you out!
All of our software is free an open to the world. None of this can be brought to you without the financial backing of our sponsors.
Β Β Β ΒWe're Dan and Jay - a two person team with a passion for open source products. We created Server Side Up to help share what we learn.
- π Blog - Get the latest guides and free courses on all things web/mobile development.
- π Community - Get friendly help from our community members.
- π€΅ββοΈ Get Professional Help - Get video + screen-sharing support from the core contributors.
- π» GitHub - Check out our other open source projects.
- π« Newsletter - Skip the algorithms and get quality content right to your inbox.
- π₯ Twitter - You can also follow Dan and Jay.
- β€οΈ Sponsor Us - Please consider sponsoring us so we can create more helpful resources.
If you appreciate this project, be sure to check out our other projects.
- The Ultimate Guide to Building APIs & SPAs: Build web & mobile apps from the same codebase.
- Building Multi-Platform Browser Extensions: Ship extensions to all browsers from the same codebase.
- Bugflow: Get visual bug reports directly in GitHub, GitLab, and more.
- SelfHost Pro: Connect Stripe or Lemonsqueezy to a private docker registry for self-hosted apps.
- serversideup/php Docker Images: PHP Docker images optimized for Laravel and running PHP applications in production.
- Financial Freedom: Open source alternative to Mint, YNAB, & Monarch Money.
- AmplitudeJS: Open-source HTML5 & JavaScript Web Audio Library.