Laravel starter
Start a Laravel app from our starter in the dashboard, or with Laravel's own installer, then add a database, a queue worker and the scheduler.
Updated 17 Oct 20264 min read
The quickest start is our Laravel starter: choose it in the dashboard, and a new Laravel app is live on its free address in a few minutes, with its key made for you. If you have Laravel code already, or want to start with Laravel's own installer, follow the steps after it: add one line to bootstrap/app.php, push, then add a shared MySQL database, tick the pdo_mysql extension, paste four variables, and add a worker and the scheduler. No tanzahost.json is needed: we read composer.json and package.json.
Start from our starter
On a new account, choose Laravel under What are you building? on the dashboard's home, then make your project. In a project you already have, choose Add a service, then App, and under Where's your code? choose Starter, then Laravel.
Give the app a name, set its limits, and choose Deploy.
The starter is Laravel 13's official skeleton, with its composer.lock, and without a front-end build, so the first deploy is quick. Before it builds, the app gets its variables once: a fresh APP_KEY, APP_ENV=production, APP_DEBUG=false, sessions in cookies (SESSION_DRIVER=cookie), the cache in files (CACHE_STORE=file) and its log in the app's Logs (LOG_CHANNEL=stderr). So it runs with no database. When you add one and attach it, the database's own variables join them.
The starter is the app's first version. To change it, send your own code from GitHub or a ZIP file with Send new code on the app's Code card: the steps below make the same kind of project on your computer.
Start with Laravel's installer
This is how Asha starts her shop, duka, in her project duka in UK-01 · United Kingdom.
1. Make the app with Laravel's installer
You need PHP, Composer and Node.js on your computer. Then, as Laravel's own installation guide shows:
composer global require laravel/installer
laravel new duka
cd duka
npm install && npm run buildThe installer asks about a testing framework, a database and a starter kit. Pick what you like: on Tanzahost the database comes from your app's variables, whatever the installer chose.
2. Trust our front door
Visitors reach your app through our front door, which handles SSL. Tell Laravel to trust it, so the links it makes start with https. In bootstrap/app.php, inside ->withMiddleware(...):
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(at: '*');
})Visits can reach your app only through our front door, so trusting it is safe.
3. Push it to GitHub
Laravel's own .gitignore already keeps .env, vendor and node_modules out. Commit composer.lock and package-lock.json: they make every build install the same packages.
git init
git add .
git commit -m "First version of duka"
git branch -M main
git remote add origin https://github.com/asha/duka.git
git push -u origin main4. Add it as an app
On your project's page, in the Add a service card, choose App.
Give it the App name
duka.Under Where's your code?, choose GitHub, then the repository
asha/dukaand the branchmain.Choose Deploy.
The build installs your packages with composer install, then runs npm run build for your front end. The first deploy then stops at its health check, because the app has no key and no database yet. That's expected: nothing was live, so nothing broke.
5. Add a database
Back on the project's page, in Add a service, choose Database.
Choose MySQL, and under Where it runs, Shared.
Leave Add its connection details to duka's variables ticked, and add it.
Your app now has DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD and DATABASE_URL, managed by the database. You never type them.
6. Add your variables
Make a key on your computer:
php artisan key:generate --showOpen the project's Variables tab, choose the app duka, then Paste a .env file, and paste these, with your own key:
APP_KEY=base64:paste-the-key-you-just-made
APP_ENV=production
APP_DEBUG=false
LOG_CHANNEL=stderrLOG_CHANNEL=stderr sends Laravel's log to your app's Logs, live. You don't set APP_URL: it follows your app's free address, and later your domain, by itself.
7. Migrations, the health address, workers
On the app's page, in Build and run, set Before going live to
php artisan migrate --force, and Health address to/up, Laravel's own health page. Under PHP extensions, tickpdo_mysql: Laravel needs it for MySQL, and our PHP doesn't have it until you ask. Save.In Processes, choose Add a worker or scheduled task. Kind Worker, name
queue, commandphp artisan queue:work. Choose Save and restart.Add another: kind Scheduled task, name
scheduler, commandphp artisan schedule:run, timetable* * * * *(every minute).On the Code card, choose Build again.
This time the migrations run before the switch, the new version answers /up, and duka is live on its free address, like https://duka-7h3k.tanzahost.co. From now on, every push to main deploys by itself, without downtime.
Your code is read-only once deployed. Laravel's storage folder is the exception: it's kept between deploys, with your uploads and logs. Store uploaded files there, with Laravel's local or public disk.
What's next
Point your domain at it, like
duka.co.tz.Read Laravel on Tanzahost for the Laravel commands, PHP versions and extensions.
Follow Deploy Laravel with queues to add a cache and queues on Valkey.