TYPO3 developers are often faced with the same requirement: Import data into TYPO3. TYPO3 itself offers many ways to import data into the system. The DataHandler (TCE) or Extbase might come to your mind, as well as plain Doctrine DBAL queries. This post will explain my views on each of the options and their pros and cons. I don't consider any of them the general solution, but the pros and cons might help you find the one suiting your current use case best.
I always would suggest DataHandler first for the following reasons:
- API is pretty simple, build a single array and submit.
- It handles everything you can think of, and everything you don't remember:
- Hooks (indexing in solr, or whatever your system uses hooks for)
- Cache flushing
- … (things I forgot)
But there are some downsides:
- It is slow (You can tweak the DataHandler instance to skip some things and be more performant)
- It might do more than you want, e.g. history, logging, relations, permissions, hooks, cache flushing, ….
Doctrine DBAL ¶
I than would recommend Doctrine DBAL for the following reasons:
- You are in full control. You can do exactly what you want the way you want, and can optimize for memory and performance.
But it also has downsides:
- You need to remember all necessary steps and rebuild integrations, e.g. indexing into solr, triggering cache flushes, etc.
And then there is Extbase for the following reasons:
- You stay in OOP
- Most developers are probably more familiar with Extbase than the other APIs
- It was not build for that task.
- You need to add workarounds to keep performance okay.
- You still need to do extra work like triggering indexing, cache flushing, etc.
It depends ¶
I would say it depends on:
- What do you need from the system, do you need hooks, logging (history) and cache flushing?
- Do you know what you do and want to have full control over every aspect?
- How much data do you have, how much memory and time do you have?
- Do you want to keep OOP?
This is a recurring topic, but Eric Harrer finally made me write this blog post by bringing up the topic once more at the Fediverse: https://phpc.social/@ErHaWeb/111096230843826340.
Read more about:
- TCE (TYPO3 Core engine) & DataHandler: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Typo3CoreEngine/Index.html
- Doctrine DBAL: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Database/Index.html
- Example Extension importing JSON data mapped to Objects using DataHandler in the end: https://git.daniel-siepmann.de/Customers/thuecat / https://github.com/werkraum-media/thuecat
- Example Extension importing JSON data mapped to Extbase Entities using mostly Extbase for importing: https://git.daniel-siepmann.de/Customers/events / https://github.com/werkraum-media/events
I'm a professional web developer doing PHP with TYPO3 since 2012. This post covers my journey from the beginning, how I've become a web developer and how I've become a TYPO3 developer and integrator. I'll also cover my experience back in the old days as a beginner and my current experience, covering my own history as well as TYPO3 history. I hope this will be useful for you, e.g. providing insights in how to become a web developer, how to get started with TYPO3 and how our job and technologies have changed over the years.
We need to update software regularly. E.g. because our framework released a new major version containing breaking changes to APIs. It is a cumber stone and hard and boring task, not meant to be done by humans. Luckily we have computers and software we can use to automate boring tasks. Our example is about TYPO3 and Aimeos updates. TYPO3 is an open source CMS while Aimeos is an open source shop framework. I'll share my experience how to automate the boring tasks during one update and how to use the automation while upgrading further installations. We will check out rector and show how you can use existing rules with custom configuration to auto mate your code migrations.
I find motivation crucial. It is the most important energy that drives us. Everyone has different motivations, but it is essential to every one of us. I currently lack motivation to write new blog posts. And I decided to write down my thoughts why I lack motivation and what actually motivates me. Maybe that will help some of you to learn from it regarding your own motivation.
Oliver Klee likes this.
Uwe Michelfelder reshared this.
https://friendica.daniel-siepmann.de/profile/typo3blogs/contacts/following lists all currently mirrored feeds.