DEV Community

Sebastian Michaelsen
Sebastian Michaelsen

Posted on

Running TYPO3 with 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. 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 - 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 and realized that I didn't necessarily need Apache or nginx for TYPO3 but the built-in PHP server 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 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';
}
Enter fullscreen mode Exit fullscreen mode

Thanks to @dakira for giving me the crucial nudge on twitter.

Top comments (1)

Collapse
 
azazqadir profile image
Muhammad Azaz Qadir

I used Valet+Envoyer+Cloudways for my typo3 websites. Quite an effective workflow. I can quickly create the server on localhost and connect to git then quickly deploy from git to the server.