Running TYPO3 with Valet
Tags: typo3, php, valet
Published: 2018-08-10 09:48:20

---
title: Running TYPO3 with Valet
published: true
description: There are a lot of ways to create a local dev environment for TYPO3 and all claim to be super easy and quick to set up - here's why Valet won me over.
tags: typo3, php, valet
---

> This article describes my experiences with developing TYPO3 on a Mac. If you're working on another OS you may or may not find this article helpful.

There are a lot of ways to create a local dev environment for TYPO3 and all claim to be super easy and quick to set up - here's why Valet won me over.

I've been developing TYPO3 websites and extensions since > 12 years and I claim to have used or at least tried every possible dev setup that ever existed for TYPO3 (probably not entirely true - try me).

An option I used for quite some time was Vagrant boxes, which I configured with [PuPHPet](https://puphpet.com/). After that other virtual machine based solutions followed, including docker and ddev. What I dislike about running my TYPO3 environment in a container is the command line access. Yes - all of those solutions allow you to ssh into the container and do what ever you like. But I didn't want that. I wanted to run `composer install` on my local machine and flush the TYPO3 cache or setup extensions [via composer scripts](https://github.com/TYPO3-Console/composer-auto-commands) - for example. I was always having headaches with this stuff.

Then I learned about how to install, maintain and run [PHP in multiple versions and MySQL with homebrew](https://getgrav.org) and realized that I didn't necessarily need Apache or nginx for TYPO3 but the [built-in PHP server](http://php.net/manual/en/features.commandline.webserver.php) works fine for most use cases.

But the built-in server has one major limitation. It can only handle one request at a time, which has at least two negative consequences:

* Loading a page with many assets and AJAX requests (like the TYPO3 backend) took its time because the requests were not processed simultaneously.
* Sometimes parallel requests are necessary, for example when you try to index page content for solr in the TYPO3 backend - that backend requests makes a request to the TYPO3 frontend, which stalls because there's already an active backend request (I eventually found a workaround for this).

After ignoring 2 or 3 hints, this week I finally tried [Valet](https://github.com/laravel/valet) and was immediatelly sold when I learned that it worked with the brew PHP / MySQL that I already had. The benefits it brings is an nginx server which works surprisingly well without any configuration at all. You just tell Valet a projects root folder and it takes care of creating vHosts for your projects. `~/projects/acme/` automagically becomes available as http://acme.test. Zero config per project required. The TLD `.test` can be reconfigured if you prefer something else. Bottom line: It took me minutes to get Valet installed and my current project running with it.

It comes with drivers to detect and run many PHP frameworks and systems including TYPO3. Only caveat: It assumes that the document root folder in your TYPO3 project is called `web`. This is not the case in all of my projects. My more recent ones use `public`. I was able to quickly solve that by placing this custom driver at `~/.valet/Drivers/Typo3PublicFolderValetDriver.php`:

```
<?php

class Typo3PublicFolderValetDriver extends Typo3ValetDriver
{
    protected $documentRoot = '/public';
}
```

Thanks to @dakira for giving me the [crucial nudge](https://twitter.com/dakira/status/1027135773953482752) on twitter.