• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    PHP
  • License
    Other
  • Created about 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

💶 User facing application for the Wikimedia Deutschland fundraising.

Build Status Code Coverage Scrutinizer Code Quality

User facing application for the Wikimedia Deutschland fundraising.

Installation

First setup

For development, you need to have Docker and docker-compose installed. You need at least Docker Version >= 17.09.0 and docker-compose version >= 1.17.0. If your OS does not come with the right version, please use the official installation instructions for Docker and docker-compose. You don't need to install other dependencies (PHP, Node.js, MariaDB) on your machine.

Get a clone of our git repository and then run:

make setup

This will

Installing the current dependencies

make install-php

Will install the dependencies currently specified in composer.lock. Use this command whenever you check out a branch that has changes to composer.lock.

Running the application

docker-compose up

You can now access the application at http://localhost:8082/. Hit Ctrl-C to stop the server.

If you want to run the application in the background, use the commands

make up-app

to start it and

make down-app

to stop it.

To start the application with a debug port open, (see "How to use XDebug and PHPStorm") run,

make up-debug

Configuration

The web and CLI entry points of the application check for the APP_ENV environment variable. If it not set, the application assumes the value dev. Each environment must have a corresponding configuration file in app/config, following the name pattern of config.ENVIRONMENTNAME.json. See the section "Running in different environments" below to see how to set APP_ENV.

You can add local modifications by adding a file that follows the name pattern of config.ENVIRONMENTNAME.local.json.

The application merges the values from the configuration files with the default values from the file app/config/config.dist.json.

Fronted development

If you want to work on the client-side code of the application, you need to load it from a different source, e.g. the development server of fundraising-app-frontend running on port 7072. The configuration has the setting assets-path that you can point to a different path or even a URL.

The following setting will point your application to the frontend development server:

"assets-path": "http://localhost:7072"

The application will show a blank white page if the browser can't find the assets.

Create a test configuration that uses the MariaDB database

To speed up the tests when running them locally, the tests use SQLite instead of MariaDB. To run the tests with the real database, add the file app/config/config.test.local.json with the following content:

{
    "db": {
        "driver": "pdo_mysql",
        "user": "fundraising",
        "password": "INSECURE PASSWORD",
        "dbname": "fundraising",
        "host": "database",
        "port": 3306
    }
}

Payments

For a fully working instance with all payment types and working templates you need to fill out the following configuration data:

"operator-email"
"operator-displayname-organization"
"operator-displayname-suborganization"
"paypal-donation"
"paypal-membership"
"creditcard"

Content

The application needs a copy of the content repository at https://github.com/wmde/fundraising-frontend-content to work properly. In development, the content repository is a composer dev-dependency. If you want to put the content repository in another place, you need to configure the i18n-base-path to point to it. The following example shows the configuration when the content repository is at the same level as the application directory:

"i18n-base-path": "../fundraising-frontend-content/i18n"

A/B test campaigns.

For more information on how to set up the campaigns see "How to Create an A/B Test.

The campaign definitions are in the app/config directory. You can tell the application which files to use by editing the campaigns value in app/config/config.ENVIRONMENTNAME.json. The campaign configuration files will be merged on top of each other.

Running in different environments

By default, the configuration environment is dev and the configuration file is config.dev.json. If you want to change that, you have to pass the environment variable to make, docker and docker-compose commands.

make ci APP_ENV=prod

For docker-compose you can either put create a file called .env in the application directory and, with the contents of

APP_ENV=prod

If you want to override the defaults in the .env file, you set the variable in your shell like this:

export APP_ENV=prod

If you run a single docker container, you can pass the variable with the -e flag:

docker run -e APP_ENV=prod php some_script.php

Valid environment names are

  • dev - development environment, mostly for local development
  • test - unit testing environment
  • uat - user acceptance testing
  • prod - production

Note: PHPUnit tests are always run in the test environment configuration, regardless of APP_ENV!

Running the tests

Full CI run

make ci

This will run the tests, check the code style, do the static analysis and check the configuration files.

Run only tests only

make test

If you want to run a specific folder with tests or just one file, use the TEST_DIR parameter. Examples:

# Run the unit tests
make phpunit TEST_DIR=tests/Unit

# Run a specific test file
make phpunit TEST_DIR=tests/EdgeToEdge/Routes/AddDonationRouteTest.php

Run only code style checks

make cs

If you want to fix the code style violations, run

make fix-cs

phpstan

We perform static code analysis with phpstan during runs of make ci.

In the absence of dev-dependencies (i.e. to simulate the vendor/ code on production) you can run phpstan with the commands

docker build -t wmde/fundraising-frontend-phpstan build/phpstan
docker run -v $PWD:/app --rm wmde/fundraising-frontend-phpstan analyse -c phpstan.neon --level 1 --no-progress cli/ contexts/ src/

These tasks are also performed during the travis runs.

Emails

You can inspect all emails sent by the application via mailhog at http://localhost:8025/

Database

Resetting the database in your local environment

To drop the database and rebuild it from scratch the database, you need to stop the database container, delete the volume db-storage defined in docker-compose.yml and start the database container again.

You can shut down all containers and delete all volumes with the command

docker-compose down -v

The next time you run docker-compose up, the database container will process all SQL files in .docker/database.

Accessing the database with the command line client

To start the command line client, use the following commands:

docker-compose up -d database
docker-compose exec database mysql -u fundraising -p"INSECURE PASSWORD" fundraising

Accessing the database from your host machine

If you want to use a different client for accessing the database, you need to connect to port 3307.

Database migrations

Out of the box, the database should be in a usable state for local development.

If you make changes to the database schema, you have to do two things:

  1. Create a Doctrine migration script for the production database. Store the migration scripts in the migrations directory of the bounded context where you made the changes.
  2. In your development environment, create the new database schema definitions with the make generate-database-schema command. This will refresh the file ./docker/database/01_Database_Schema.sql. Then restart the container environment while dropping the database volume. See section "Resetting the database in your local environment" below.

Migrations CLI and configuration

The configuration file for migrations is in app/config/migrations.php

The bin/doctrine CLI command comes with the pre-configured migrations command for the Fundraising App. Wherever the Doctrine migrations documentation mentions running the command vendor/bin/doctrine-migrations, use the command bin/doctrine instead. E.g. bin/doctrine migrations:status.

In your Docker-based development environment, run the command in the app container, using docker-compose exec. The container environment must be running for this to work. Example:

docker-compose exec app bin/doctrine migrations:status

Running migrations on the server

Have a look the deployment documentation on how to run the migrations on the server.

Note: If you're getting errors that the configuration file was nor found, make sure to set APP_ENV to the right value. See section "Running in different environments" in this document.

Accessing the database from a Docker image

If you want to connect to the database container from another docker container that's not part of the docker-compose.yml configuration (for example to use a tool like Adminer or PHPMyAdmin), you need to put that container in the same virtual network as the rest of the application containers. With the command

docker network ls

you can list all networks. There will be one network name ending in fundraising_proxy (the prefix is probably the directory name where you checked out this repository).

Next up is finding out the full name of the database container with the command

docker ps

The database container will be the one ending in _database_1. The prefix is probably the directory name where you checked out this repository.

Copy the full network name and container name and use them instead of the placeholders __CONTAINER_NAME__ and __NETWORK_NAME__ in the following command to run PHPMyAdmin, port 8099:

docker run -it --link __CONTAINER_NAME__:db --net __NETWORK_NAME__ -p 8099:80 phpmyadmin/phpmyadmin

Importing the address completion data

To import the German postcode database, you need to place it in .docker/database/00.postcodes.sql. The database container will pick it up when running for the first time (when it creates the volume db-storage). This happens when you run docker-compose up for the first time or when you reset the database (see above). Depending on the speed of you machine, the import will take up to 10 minutes. Watch the output of the database container so see when the database has finished importing.

Frontend development

By default, the application uses pre-built frontend assets from fundraising-app-frontend. To update the assets to the newest version, run

make download-assets

To get the pre-built assets from a specific branch of that repository, run

make download-assets ASSET_BRANCH=your_branch_name

If you want to load the assets from a different source, e.g. the development server of fundraising-app-frontend running on port 7072, you need to add the following line to your config.dev.json file:

"assets-path": "http://localhost:7072"

The HTML templates will prefix every asset (CSS, JavaScript) reference with the value of assets-path.

Updating the dependencies

To update all the PHP dependencies, run

make update-php

To update only the messages in the application and emails, update the fundraising-frontend-content dependency with the command

make update-content

For updating an individual PHP dependency, use the command line

docker run --rm -it -v $(pwd):/app -u $(id -u):$(id -g) registry.gitlab.com/fun-tech/fundraising-frontend-docker:composer composer update PACKAGE_NAME

and replace the PACKAGE_NAME placeholder with the name of your package.

Deployment

For an in-depth documentation how to deploy the application on our servers, see the deployment documentation.

Project structure

This app and its used Bounded Contexts follow the architecture rules outlined in Clean Architecture + Bounded Contexts.

Architecture diagram

Used Bounded Contexts:

Production code layout

  • src/: code not belonging to any Bounded Context, framework agnostic if possible
    • Factories/: application factories used by the framework, including top level factory FFFactory
    • Presentation/: presentation code, including the Presenters/
    • Validation/: validation code
  • vendor/wmde/$ContextName/src/: framework agnostic code belonging to a specific Bounded Context
    • Domain/: domain model and domain services
    • UseCases/: one directory per use case
    • DataAccess/: implementations of services that binds to database, network, etc
    • Infrastructure/: implementations of services binding to cross cutting concerns, i.e. logging
  • web/: web accessible code
    • index.php: HTTP entry point
    • skins: Asset files (CSS, JavaScript, images, fonts) for different skins
  • app/: contains application-specific configuration and all framework (Symfony) dependent code
    • Controllers/: Symfony Controllers
    • EventHandlers: "Middleware" code that performs tasks before or after HTTP request handling
    • config/: configuration files
      • config.dist.json: default configuration
      • config.test.json: configuration used by integration and system tests (gets merged into default config)
      • config.test.local.json: instance specific (gitignored) test config (gets merged into config.test.json)
      • config.development.json: instance specific (gitignored) production configuration (gets merged into default config)
  • config/: Symfony configuration files
  • cli/: Command line commands, integrated into the Symfony console
  • var/: Ephemeral application data
    • log/: Log files (in debug mode, every request creates a log file)
    • cache/: Cache directory for Twig templates and Symfony DI containers

Test code layout

The test directory structure (and namespace structure) mirrors the production code. Tests for code in src/ and app/ is in tests/.

Tests are categorized by their type. To run only tests of a given type, you can use one of the test suites defined in phpunit.xml.dist.

  • Unit/: small isolated tests (one class or a small number of related classes)
  • Integration/: tests combining several units
  • EdgeToEdge/: edge-to-edge tests (fake HTTP requests to the framework)
  • System/: tests involving outside systems (i.e., beyond our PHP app and database)
  • Fixtures/: test doubles (stubs, spies and mocks)

If you need access the FunFunFactory in your non-unit tests, for instance to interact with persistence, you should inherit from KernelTestCase and get the Factory from the container.

Test type restrictions

Network Framework (Symfony) Top level factory Database and disk
Unit No No No No
Integration No No Discouraged Yes
EdgeToEdge No Yes Yes Yes
System Yes Yes Yes Yes

Other directories

  • .docker/: Configuration and Dockerfiles for the development environment

See also

More Repositories

1

Diff

䷂ Library for diffing, patching and representing differences between objects
PHP
200
star
2

wikibase-docker

LEGACY 🐳 Docker images and example compose file for Wikibase and surrounding services
Shell
183
star
3

wikibase-release-pipeline

TypeScript
44
star
4

phragile

DISCONTINUED: 📈 Sprint overviews and data visualizations for Phabricator projects
PHP
37
star
5

WikibaseDataModel

⚙ PHP implementation of the Wikibase Data Model
PHP
35
star
6

php-vuejs-templating

VueJS templating implementation in PHP
PHP
26
star
7

Wikiba.se-2017

The Wikiba.se website
22
star
8

Lizenzhinweisgenerator

© An application that helps generating a legally correct attribution with images from Wikipedia, Wikimedia Commons or any other online resource
JavaScript
22
star
9

wikit

✨ The Wikibase Design System and home of WMDE-supported component implementations.
TypeScript
19
star
10

Number

Numerical value objects, parsers and formatters
PHP
18
star
11

wikidata-mismatch-finder

A tool to review mismatches between Wikidata and External Databases
PHP
14
star
12

wikidata-constraints-violation-checker

a tool to analyze constraint violations on Wikidata
Python
12
star
13

fundraising-donations

Bounded Context for the Wikimedia Deutschland fundraising donation subdomain
PHP
11
star
14

Time

Time value objects, parsers and formatters
PHP
11
star
15

Ask

DISCONTINUED: Library containing a PHP implementation of the Ask query language.
PHP
11
star
16

WikidataApiGem

RubyGem for using the Wikidata API
Ruby
10
star
17

WikibaseDataModelJavaScript

JavaScript implementation of the basic Wikibase DataModel entity types and components they are made of
JavaScript
10
star
18

fundraising-memberships

Bounded Context for the Wikimedia Deutschland fundraising membership subdomain
PHP
9
star
19

WikibaseDataModelSerialization

Serializers and deserializers for the Wikibase DataModel
PHP
9
star
20

query-builder

MOVED TO https://gerrit.wikimedia.org/r/admin/repos/wikidata/query-builder 🔍️ A simple query builder for Wikidata SPARQL queries
TypeScript
7
star
21

wikibase-rest-api-proposal

A schema proposal for the future Wikibase REST API.
JavaScript
7
star
22

PsrLogTestDoubles

Test Doubles for the PSR-3 Logger Interface
PHP
6
star
23

wikidata-who-am-i

Vue
6
star
24

WikibaseInternalSerialization

Serializers and deserializers for the serialization used in the Wikibase Repo data access layer
PHP
6
star
25

wbaas-deploy

Code to deploy wikibase.cloud and related infrastructure
HCL
5
star
26

WikidataBuilder

DEPRECATED: Script to build the Wikidata extension for deployment
JavaScript
5
star
27

Serialization

Small library defining a Serializer and a Deserializer interface.
PHP
5
star
28

DataValuesJavaScript

JavaScript implementations of all basic DataValue classes, associated parsers and formatters
JavaScript
5
star
29

wikidata-map

A frontend to render density of wikidata items on a map.
JavaScript
5
star
30

email-address

Email Address value object written in PHP 7
PHP
4
star
31

fundraising-banners-until-2022

Code of all the fundraising banners
JavaScript
4
star
32

wbaas-deploy-public

Public snapshot of wbaas-deploy
HCL
4
star
33

intellij-settings

Settings for IntelliJ based IDEs
4
star
34

WikibaseDatabase

DISCONTINUED: No longer maintained simple database abstraction layer
PHP
4
star
35

less-variable-resolver

💱 Resolve variables defined by other variables' values - to allow for conversion into languages not supporting lazy evaluation.
JavaScript
4
star
36

reference-island

🏝️Data pipieline to extract reference for Wikidata
Python
4
star
37

wikidata-wikibase-architecture

Wikidata and Wikibase architecture documentation
JavaScript
4
star
38

vuex-helpers

Helper functions to ease working with Vuex, Centralized State Management for Vue.js.
TypeScript
4
star
39

WikiLovesMonuments

Enable easier image uploads on the German Wikipedia for Wiki Loves Monuments competition.
Python
3
star
40

WikibaseReconcileEdit

PHP
3
star
41

FundraisingStore

Persistence services around the fundraising database
PHP
3
star
42

DeepCat-Gadget

[DISCONTINUED] Gadget for MediaWiki using JSONP CatGraph interface
JavaScript
3
star
43

catgraph-jsonp

[DISCONTINUED] jsonp interface to catgraph
Python
3
star
44

WikibaseDataModelServices

A collection of services around Wikibase DataModel
PHP
3
star
45

wdio-wikibase

WebdriverIO plugin for testing a Wikibase repo.
JavaScript
3
star
46

wikidata-wikibase-vision

MOVED: Team owned and developed technical vision diagram for Wikidata & Wikibase.
JavaScript
3
star
47

WikibaseDataModelTypes

Typescript definitions for the Wikibase DataModel expressed as flat JS objects
TypeScript
3
star
48

git-filter-repo-docker-action

A GitHub Docker Action to run git-filter-repo and push the result to a GitHub repository using ssh
Shell
3
star
49

Clock

🕓 Simple interface to get the current time without binding to global system resources
PHP
3
star
50

WikiLovesDownloads

Tool to create lists of URLs to files within a given category on a Wiki
JavaScript
3
star
51

eslint-config-wikimedia-typescript

ESLint config for TypeScript following Wikimedia code conventions.
JavaScript
3
star
52

DataTypes

[READ-ONLY] This component has been converted to a MediaWiki extension and is hosted on Gerrit now.
PHP
3
star
53

Euro

💶 PHP value object for representing a positive amount of Euro
PHP
2
star
54

wikibase-seed-data

JavaScript
2
star
55

PhabMetrics

Collection of scripts to assist in calculating some metrics from a phabricator instance
JavaScript
2
star
56

WikibaseRepository

[ARCHIVED] Experimental split of Wikibase.git | MediaWiki extension that lets you store and collaboratively manage structured data
PHP
2
star
57

new-lexeme-special-page

Source code for the new version (since 2022) of the Special:NewLexeme special page in WikibaseLexeme
TypeScript
2
star
58

WikibaseManifest

[DISCONTINUED] PROTOTYPE WikibaseManifest
PHP
2
star
59

wbs_propertypairs

Archive of wbs_propertypairs generated by / for Wikidata property suggester
2
star
60

fun-validators

General and shared validation services created as part of the WMDE fundraising software
PHP
2
star
61

commons-category-counter

A tool that determines the number of files within a given category and its subcategories on particular dates within a defined period.
PHP
2
star
62

Datentankstelle

Data pump for downloading free licensed E-Books, music, maps and other data.
PHP
2
star
63

wikidata-item-quality-evaluator

a tool to get ORES quality scores for a list of Wikidata Items
Vue
2
star
64

fundraising-subscriptions

Bounded context for subscriptions in the fundraising code base
PHP
2
star
65

iterable-functions

Functions to transform iterables into more specific types
PHP
2
star
66

JourneyModel

DEPRECATED: circa 2019 Wikidata Work Process
2
star
67

fundraising-payments

Bounded Context for the Wikimedia Deutschland fundraising payment subdomain
PHP
2
star
68

MSWissenschaft

A contribution from Wikimedia Germany to the traveling science exhibition on board the riverboat MS Wissenschaft.
JavaScript
2
star
69

wikibase-metadata

Suite Scraper - Scrape relevant metrics and metadata from known wikibase instances
Python
2
star
70

WikibaseQuery

DISCONTINUED: Wikibase Query adds query capabilities to Wikibase Repo
PHP
2
star
71

WikibaseSerializationJavaScript

Wikibase datamodel serialization implementation in JavaScript
JavaScript
2
star
72

commons-video-clicks

This tool is used to query video tracking data of video resources on commons.wikimedia.org. It allows exporting them as a CSV file.
HTML
1
star
73

wikibase-vue

[READ-ONLY] Code experiment for Wikibase SSR using vue.js done in 2017. The actual implementation happens in https://gerrit.wikimedia.org/r/#/admin/projects/wikibase/termbox
JavaScript
1
star
74

wikiba.se

OLD & ARCHIVED Wikibase website
HTML
1
star
75

WikibaseEntityStore

DISCONTINUED: Wikibase EntityStore provides persistence services for Wikibase entities.
PHP
1
star
76

doctrine-term-store

[READ-ONLY] Small library for persistence of Wikibase terms via Doctrine DBAL. Proof of concept work in 2019. Not made it to be actually used.
PHP
1
star
77

grafana-dashboards

DEPRECATED: Store for the JSON of the WMDE grafana dashboards
PHP
1
star
78

fundraising-browsertests

Browsertests for the WMDE fundraising application
Ruby
1
star
79

puppet-phragile

DEPRECATED: Puppet module for Phragile for phragile.wmflabs.org. Integrated into https://gerrit.wikimedia.org/r/admin/projects/operations/puppet
Puppet
1
star
80

lib-version-check

A small utility to check remote library versions against a local dependency entry.
JavaScript
1
star
81

connecting-senses

A tool to connect Lexeme Senses to Wikidata Items
TypeScript
1
star
82

eslint-plugin-resource-loader

JavaScript
1
star
83

otrs-address-extractor

Command line tool to extract addresses from an OTRS CSV export.
PHP
1
star
84

tictac

Python
1
star
85

attribution-generator-api

JavaScript
1
star
86

LOSH-Frontend

TypeScript
1
star
87

wmde-access

Tool showing who at WMDE SWE has access to what in the Wikimedia landscape
PHP
1
star
88

faktenpruefenimnetz

Website for fakten.wikimedia.de
CSS
1
star
89

picsome

TypeScript
1
star
90

wikibase-registry

Wikibase Registry setup
PHP
1
star
91

prototype-wikibase-graphql-api

GraphQL API Prototyping April 2020
JavaScript
1
star
92

prototyp_mobile_termbox

[READ-ONLY] Wikidata mobile Termbox prototype
Vue
1
star
93

StatsdClient

Client for etsy/statsd. Adapts into statsd-php-client via well designed interfaces
Makefile
1
star
94

hamcrest-html-matchers

Set of Hamcrest matchers for HTML assertrions
PHP
1
star
95

jahresbericht2018

JavaScript
1
star
96

wikibase-docker-compose-generator

[DISCONTINUED] Web form to allow Wikibase docker users to setup a docker file by answering simple questions
JavaScript
1
star
97

capx-pilot

Development environment for the Capacity Exchange pilot site
Shell
1
star
98

wikit-css

[DISCONTINUED] A repository to hold the design system tokens file and component storybook
CSS
1
star
99

wikibase-term-store

[READ-ONLY] Small library for looking up terms by item or property id or finding ids by term
PHP
1
star
100

catgraph-client-python

Python code to talk to Catgraph.
Python
1
star