This is my local developer enviroment. My base sitepackage skom_sitepackage is preinstalled.
- devTYPO3v10DDEV
The basic idea behind this project is to have an optimal development environment that I can use as a basis for all new customer projects. All modern best practices for TYPO3 projects should be applied. The development environment should also provide all the necessary linting and testing tools. Furthermore, automated deployment to a beta-server as well as to the live-server should be as easy as possible.
A latest version of Docker and ddev-local must be available on the local system.
mkdir myNewProject
cd myNewProject
git clone https://github.com/Starraider/devTypo3ddev . [1]
git submodule update --init --recursive
[1]: If you get an error msg on MacOS, saying your folder is not empty: rm .DS_Store
Change the project name in .ddev/config.yaml and .env (must be the same name in both files, use lowercase):
mcedit .ddev/config.yaml [2]
name=my-project
mcedit .env [2]
PUBLIC_URL="https://my-project.ddev.site/"
ddev start
ddev composer install
ddev exec yarn install
ddev db-restore
ddev fileadmin-restore
[2]: You can of course use your favorite editor to edit the files.
Before start working with your freshly installed project, follow the next steps:
For your own project you should detach your lokal repo from the original Github repo:
git remote rm origin
Later you will edit the styles and templates etc. in your own custom sitepackage. We already installed a custom sitepackage as a starting point for you in /packages/custom_sitepackage. You should detach the custom_sitepackage from its original repo as well:
git rm --cached packages/customer_sitepackage
rm .gitmodules
rm -rf packages/customer_sitepackage/.git
rm -rf packages/customer_sitepackage/.github
rm -rf .git/modules/packages/customer_sitepackage
hub create
git push -u origin HEAD
After Setup you should restart ddev:
ddev restart
Now you can start the project in your webbrowser in 3 different ways:
ddev open // Opens TYPO3-Frontend
or
ddev open -t // Opens TYPO3-Backend
or just open https://my-project.ddev.site in your Webbrowser.
TYPO3-Backend Login: Username: dev-admin Passwort (same for the Intalltool): admin123
phpMyAdmin: http://ddev-typo3.ddev.site:8036/
(Attention: don't use "https://" !)
Single command execution:
ddev exec <command>
Interactive bash:
ddev ssh
Here you can find more usefull ddev commands
Use 'ddev typo3cms ...' to use the TYPO3-Console.
Here you can find more usefull console commands
Run 'ddev db-backup' to generate a backup of the DB.
Run 'ddev db-restore' for restoring the DB.
Run 'ddev fileadmin-restore' to restore the files in fileadmin.
If you run 'ddev warmup-dev' every page from the sitemap will be fetched by wget to warm up the caches.
Run 'ddev t3cron' if you need the Scheduler.
For deployment we use Deployer.
Before the first deployment, you must enter your beta-server and live-server credentials in the deployer.php file.
First deployment will fail, because you have to edit the .env file, which is automatically generated during the first deployment at the shared folder.
On the beta-server edit the .env file to:
TYPO3_CONTEXT="Development//Beta"
INSTANCE="beta"
PUBLIC_URL="https://your.beta-server.tld/"
And fill in the DB credentials of the beta-server.
On the live-server edit the .env file to:
TYPO3_CONTEXT="Production"
INSTANCE="live"
PUBLIC_URL="https://your.live-server.tld/"
And fill in the DB credentials of the live-server.
php vendor/bin/dep deploy -vv beta
php vendor/bin/dep deploy -vv live
If something went wrong, you have to unlock the deployment:
php vendor/bin/dep deploy:unlock -vv beta
php vendor/bin/dep deploy:unlock -vv live
Rector can help you with maintenance your PHP code by analyse it for changes you should fix. Rector can even change your code for you. With the additional TYPO3-Rectors it can help you with keeping up with the changes in the TYPO3-System. [more >>]
Dry run:
vendor/bin/typo3-rector process packages/customer_sitepackage --dry-run
Let's rector do the work for you:
vendor/bin/typo3-rector process packages/customer_sitepackage
You can config Rector in the rector.php file.
Linter for TypoScript. [more >>]
typoscript-lint path/to/your.typoscript
Example:
typoscript-lint packages/customer_sitepackage/Configuration/TypoScript/setup.typoscript
Linter for CSS, SCSS, SASS, and LESS files. [more >>]
npx stylelint --config ./.stylelintrc.json "path/to/dir/**/*.scss"
Example:
npx stylelint --config ./.stylelintrc.json "packages/customer_sitepackage/**/*.{css,scss}"
Linter for JavaScript, yaml and markdown files, which can also automatically correct coding standard violations. [more >>]
npx eslint "path/to/dir/**/*.js"
npx eslint --fix "path/to/dir/**/*.js"
npx eslint "path/to/file/file.yaml"
npx eslint . --ext .yml
npx eslint file.md
Example:
npx eslint "packages/customer_sitepackage/**/*.js"
npx eslint "packages/customer_sitepackage/**/*.{yaml,yml}"
npx eslint README.md
Bootlint is a HTML linter for bootstrap projects. [more >>]
npx bootlint "path/to/dir/**/*.html"
Example:
npx bootlint "packages/customer_sitepackage/**/*.html"
PHP CodeSniffer is a linter, which can also automatically correct coding standard violations.
Configuration file: phpcs.ruleset.xml [more >>]
vendor/bin/phpcs path/to/dir
vendor/bin/phpcs path/to/file
Examples:
vendor/bin/phpcs packages/customer_sitepackage
Use phpcbf to automatically fix as many errors as possible.
vendor/bin/phpcbf path/to/dir -vv
vendor/bin/phpcbf path/to/file -vvv
PHP code standard fixer. [more >>]
To fix your php files automaticly:
vendor/bin/php-cs-fixer fix path/to/dir
vendor/bin/php-cs-fixer fix path/to/file
If you use the dir syntax all subdirs will be checked as well!
To make a dry run:
vendor/bin/php-cs-fixer fix --dry-run path/to/file
To show details use the parameter -v -vv or -vvv
Examples:
vendor/bin/php-cs-fixer fix packages/customer_sitepackage -v
vendor/bin/php-cs-fixer fix public/typo3conf/ext/skom_sitepackage --dry-run -vvv
PHP linter. [more >>]
vendor/bin/phpstan analyse --level 0..8 path/to/dir
Example:
vendor/bin/phpstan analyse -l 5 public/typo3conf/ext/skom_sitepackage
Very fast php linter. [more >>]
vendor/bin/parallel-lint path/to/dir
vendor/bin/parallel-lint path/to/file
Example:
vendor/bin/parallel-lint public/typo3conf/ext/skom_sitepackage
PHP linter checking for possible bugs, suboptimal code, overcomplicated expressions and unused code. [more >>]
vendor/bin/phpmd path/to/dir format ruleset
format can be: xml, text, ansi (best for terminal output), html, json.
rulesets are: codesize,unusedcode,naming,cleancode,controversial,design
Example:
vendor/bin/phpmd public/typo3conf/ext/skom_sitepackage ansi codesize,unusedcode,naming
To get some statistics about your PHP project, you could use phploc [more >>]
vendor/bin/phploc path/to/dir
Example:
vendor/bin/phploc packages/customer_sitepackage
vendor/bin/phploc public/typo3conf/ext/skom_sitepackage
Linter for HTML files or websites. Be aware this linter doesn't work with fluid templates! But it can check websites! [more >>]
npx htmlhint path/to/dir
npx htmlhint https://www.mywebsite.de
Developed 2020 by Sven Kalbhenn
If you have any questions about this project or just want to talk: Send me a message sven@skom.de