Skip to content

Starraider/devTypo3ddev

Repository files navigation

devTYPO3v10DDEV

Donate GitHub CodeFactor GitHub issues Lint Code Base

This is my local developer enviroment. My base sitepackage skom_sitepackage is preinstalled.

Basic concept

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.

Prerequisites

A latest version of Docker and ddev-local must be available on the local system.

Installation

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.

Setup

Before start working with your freshly installed project, follow the next steps:

1. Detach from original repo

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

2. Config the beta-server

3. Config the live-server

4. Make your own Github repo

hub create
git push -u origin HEAD

Start and Login

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

Database

phpMyAdmin: http://ddev-typo3.ddev.site:8036/

(Attention: don't use "https://" !)

Useful ddev commands

Single command execution:

ddev exec <command>

Interactive bash:

ddev ssh

Here you can find more usefull ddev commands

TYPO3-Console

Use 'ddev typo3cms ...' to use the TYPO3-Console.

Here you can find more usefull console commands

Defined commands

db-backup

Run 'ddev db-backup' to generate a backup of the DB.

db-restore

Run 'ddev db-restore' for restoring the DB.

fileadmin-restore

Run 'ddev fileadmin-restore' to restore the files in fileadmin.

warmup-dev

If you run 'ddev warmup-dev' every page from the sitemap will be fetched by wget to warm up the caches.

cron

Run 'ddev t3cron' if you need the Scheduler.

Deployment

For deployment we use Deployer.

First deployment

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.

Deployment to beta- or 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

Testing

Code maintenance

(TYPO3-)Rector

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.

Linting

TypoScript Linter

Linter for TypoScript. [more >>]

typoscript-lint path/to/your.typoscript

Example:

typoscript-lint packages/customer_sitepackage/Configuration/TypoScript/setup.typoscript

(S)CSS Linter

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}"

eslint

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

Bootlint is a HTML linter for bootstrap projects. [more >>]

npx bootlint "path/to/dir/**/*.html"

Example:

npx bootlint "packages/customer_sitepackage/**/*.html"

PHP CodeSniffer

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-cs-fixer

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

phpstan

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

parallel-lint

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

phpmd

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

phploc

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

htmlhint

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