Adding New Project Types¶
Adding and maintaining project types (like typo3, magento2, etc.) is not too hard. Please update and add to this doc when you find things that have been missed.
To add a new project type:
- Add the new type to the list in
nodeps/values.go - Add to
appTypeMatrixinapptypes.go - Add to
properties.typeinddevapp/schema.json - Add to
project_typetest loop inddev-webserver/test.sh - Add to
typeintemplates.gocomments - Create a new go file for your project type, like
mytype.go. - Implement the functions that you think are needed for your project type and add references to them in your
appTypeMatrixstanza. There are lots of examples that you can start with in places likedrupal.goandtypo3.go,shopware6.go, etc. The comments in the code inapptypes.gofor theappTypeFuncsfor each type of action tell what these are for, but here’s a quick summary.settingsCreatoris the function that will create a main settings file if none exists.uploadDirreturns the filepath of the user-uploaded files directory for the project type, likesites/default/filesfor Drupal orpub/mediafor magento2.hookDefaultCommentsadds comments toconfig.yamlabout hooks with an example for that project type. It’s probably not useful at all.apptypeSettingsPathsreturns the paths for the main settings file and the extra settings file that DDEV may create (likesettings.ddev.phpfor Drupal).appTypeDetectis a function that determines whether the project is of the type you’re implementing.postImportDBActioncan do something after db import. I don’t see it implemented anywhere.configOverrideActioncan change default config for your project type. For example, your CMS may requirephp8.3, so aconfigOverrideActioncan change the php version.postConfigActiongives a chance to do something at the end of config, but it doesn’t seem to be used anywhere.postStartActionadds actions at the end ofddev start. You’ll see several implementations of this, for things like creating needed default directories, or setting permissions on files, etc.importFilesActiondefines howddev import-filesworks for this project type.defaultWorkingDirMapallows the project type to override the project’sworking_dir(whereddev sshandddev execstart by default). This is mostly not done anymore, as theworking_diris typically the project root.composerCreateAllowedPathsspecifies the paths that can exist in a directory whenddev composer create-projectis being used.
- You’ll likely need templates for settings files, use the Drupal or TYPO3 templates as examples, for example
pkg/ddevapp/drupalandpkg/ddevapp/typo3. Those templates have to be loaded at runtime as well. - Implement
nginx-site-<project-type>.confinwebserver_config_assets. You can usewebserver_config_assets/nginx-site-php.confas a pattern, or something from the upstream project. - Upload the project detection file stubs to the
testdata/TestDetectAppTypefolder. - Add to
appTypestest slice forTestConfigOverrideActioninddevapp/apptypes_test.go. - If the project type has a custom command, add it to
global_dotddev_assets/commands/webfolder. - Once your project type starts working and behaving as you’d like, you’ll need to add test artifacts for it and try testing it (locally first).
- Add your project to
TestSitesinddevapp_test.go. - Create a DDEV project named
testpkg<projectype>somewhere and get it going and working with a database and files you can export. - Export the database, files, and (optionally) code to tarballs or
.sql.gz. Put them somewhere on the internet—they’ll end up inddev/test-<projectype>. We will give you permissions on that if you like. Themagento2project has descriptions explaining how each tarball gets created. Do that for yours as well. - Run the test and get it working. I usually use the trick of setting
GOTEST_SHORT=<element_in_TestSites>, likeGOTEST_SHORT=7. Then set that environment variable in the GoLand profile or your environment.export GOTEST_SHORT=7 && make testpkg TEST_ARGS="-run TestDdevFullsiteSetup"
- Add your project to
- (We can assist you with this step if needed) Upload your project to GitHub or create an upstream fork (example for Laravel):
- Create a
ddev-automated-testbranch, set it as the default. - Commit all vendor dependencies, but don’t commit the
.ddevdirectory. - Update the
README.mdinstructions. - Create a new release and attach the database and file artifacts.
- Transfer the repository to DDEV, we will maintain your access. (Ask us to do this after opening the PR.)
- Create a
- Update the documentation:
- If it doesn’t pass our spell check, add the word to
.spellcheckwordlist.txt - Add the new type to
users/configuration/config.md - Update the
users/quickstart.md - If there is a new command, add it to
users/usage/commands.mdandusers/usage/cli.md
- If it doesn’t pass our spell check, add the word to